1
votes

I am using protractor Version 5.4.2 in window 10 OS, to script I use Eclipse Java EE IDE for Web Developers.Version: Photon Release (4.8.0) with Tern plugin.

I get no default proposals for browser.actions(). Also my execution is fails due to below error .

Message: Failed: browser.actions(...).dragAndDrop(...).perfrom is not a function Stack: TypeError: browser.actions(...).dragAndDrop(...).perfrom is not a function at UserContext. (F:\Learning\Repositories\protractor-sam-test-scripts\EclipsePro\src\com\sam\scriptjs\draganddrop.spec.js:15:45) at C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:112:25 at new ManagedPromise (C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:1077:7) at ControlFlow.promise (C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2505:12) at schedulerExecute (C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:95:18) at TaskQueue.execute_ (C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3084:14) at TaskQueue.executeNext_ (C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:3067:27) at asyncRun (C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:2974:25) at C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\promise.js:668:7 at From: Task: Run it("Drag and drop") in control flow at UserContext. (C:\Users\sam\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd2\index.js:94:19) From asynchronous test: Error at Suite. (F:\Learning\Repositories\protractor-sam-test-scripts\EclipsePro\src\com\sam\scriptjs\draganddrop.spec.js:11:4) at Object. (F:\Learning\Repositories\protractor-sam-test-scripts\EclipsePro\src\com\sam\scriptjs\draganddrop.spec.js:2:1) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12)

I already updated my protractor and webdriver-manager versions , but the error still persists.

Please see my spec.js

//draganddrop.spec.js
describe('drag and drop trial', function() {


      //Each single it function is a test script
      it('first spec', function() {
          browser.driver.get('https://codef0rmer.github.io/angular-dragdrop/#!/');
        expect(browser.getTitle()).toEqual('Drag and Drop for AngularJS');
      });

      it('Drag and drop', function() {
           var from=element(by.model('list1'));
           var to=element(by.model('list2'));
          //drag and drop source  to Destination
           browser.actions().dragAndDrop(from,to).perfrom();
           browser.sleep(7500);
          });

}) 
1

1 Answers

0
votes

Try with this code:

    //1st way: dragging one element to another
    browser.actions().mouseDown(from).mouseMove(to).mouseUp().perform();

There are 3 ways of implementing dragAndDrop in which I found this approach in protractor the most fitting.