electron-userland / spectron

DEPRECATED: 🔎 Test Electron apps using ChromeDriver
http://electronjs.org/spectron
MIT License
1.68k stars 229 forks source link

Do we have access to actions from the WebDriverio API? #260

Open HairyMaclary opened 6 years ago

HairyMaclary commented 6 years ago

I am unable to drag and make a selection, with something like this:

        await this.app.client.moveToObject(Element, 50, 50);
        await this.app.client.buttonDown();
        await this.app.client.moveToObject(Element, 200, 50);
        await this.app.client.buttonUp();

The cursor moves but the selection isn't created. So, it turns out that buttonUp and buttonDown are depreciated in WebDriverIO. It appears that they have been recently replaced with app.client.actions().

When I try to use actions I get a typescript error:

TypeError: this.app.client.actions is not a function

Are actions exposed in Spectron or are the typings all wrong? Ta...

HairyMaclary commented 6 years ago
  "devDependencies": {
    "@types/jest": "^21.1.5",
    "@types/node": "^8.0.47",
    "@types/webdriverio": "^4.8.7",
    "electron": "^1.7.9",
    "jest": "^21.2.1",
    "jest-teamcity": "^1.3.0",
    "spectron": "^3.7.2",
    "ts-jest": "^21.1.4",
    "tslint": "^5.8.0",
    "tslint-language-service": "^0.9.6",
    "typescript": "^2.3.4",
    "wdio-teamcity-reporter": "^1.1.1"
  },
christian-bromann commented 6 years ago

@HairyMaclary try to reinstall your dependencies. The actions command was introduced in WebdriverIO with v4.9.0.

jadams760 commented 6 years ago

actions is missing in @types/webdriverio@4.8.8, currently the latest version. However, I think actions may not be exposed in Spectron because I am receiving the following error

unknown command: session/b93cf790f87bf687840d78502f33fc34/actions

   at new RuntimeError (../node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
   at Request._callback (../node_modules/webdriverio/build/lib/utils/RequestHandler.js:297:39)
   at Request.Object.<anonymous>.Request.init.self.callback (../node_modules/request/request.js:186:22)
   at Request.emit (../events.js:159:13)
   at Request.<anonymous> (../node_modules/request/request.js:1163:10)
   at Request.emit (../events.js:159:13)
   at IncomingMessage.<anonymous> (../node_modules/request/request.js:1085:12)
   at Object.onceWrapper (../events.js:254:19)
   at IncomingMessage.emit (../events.js:164:20)
   at endReadableNT (../_stream_readable.js:1054:12)
   at _combinedTickCallback (../internal/process/next_tick.js:138:11)
   at process._tickDomainCallback (../internal/process/next_tick.js:218:9)

when calling actions () with an actions parameter

const elementLocation = await app.client.getLocation ("#clickable-element");

const actions =
[
   {
      type: "pointer",
      id: "click",
      parameters: { pointerType: "mouse" },
      actions:
      [
         { type: "pointerMove", duration: 1000, x: elementLocation.x, y: elementLocation.y },
         { type: "pointerDown", button: 0 },
         { type: "pause", duration: 1000 },
         { type: "pointerUp", button: 0 },
      ],
   },
];

await (this.app.client as any).actions (actions);

as well when just calling without any parameter

await (this.app.client as any).actions ();

which should just release the action, according to the source code.

In my test I am using:

"@types/webdriverio": "4.8.8",
"electron": "1.8.2",
"spectron": "3.8.0",
"webdriverio": "4.10.2"
christian-bromann commented 6 years ago

@jadams760 right, this is because it hasn't landed in Chromedriver yet. I believe the Chromium team is working on getting this out asap. However this issue can neither be fixed in WebdriverIO nor in Spectron. We just need to wait until the WebDriver spec compatibility has improved.

HairyMaclary commented 6 years ago

Looks like they are still working on it:

https://bugs.chromium.org/p/chromedriver/issues/detail?id=1897

BTW, @christian-bromann , thanks for all your great work!

wburgess-invision commented 6 years ago

Damn - just built out a custom drag and hit the same error. Thanks for digging that it's not supported yet.