vendredi 26 octobre 2018

Selenium "Unrecognized command: actions"

I am trying to do a mouse click base on position. However, I can't seem to make action work an always get the following message. I reproduced the problem by trying to double click on google.com main search bar.

For help, see: https://nodejs.org/en/docs/inspector (node:38864) UnhandledPromiseRejectionWarning: UnknownCommandError: Unrecognized command: actions warning.js:18 at buildRequest (c:\GitRepo\MMT4\src\javascript\Web.Tests\node_modules\selenium-webdriver\lib\http.js:375:9) at Executor.execute (c:\GitRepo\MMT4\src\javascript\Web.Tests\node_modules\selenium-webdriver\lib\http.js:455:19) at Driver.execute (c:\GitRepo\MMT4\src\javascript\Web.Tests\node_modules\selenium-webdriver\lib\webdriver.js:696:38) at process._tickCallback (internal/process/next_tick.js:68:7) (node:38864) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3) warning.js:18 (node:38864) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

imported the packages with npm

"devDependencies": {
    "@types/node": "^10.12.0"
},
"dependencies": {
    "chromedriver": "^2.43.0",
    "selenium-webdriver": "^4.0.0-alpha.1"
}

According to the documentation I found here, it should to work https://seleniumhq.github.io/selenium/docs/api/javascript/index.html https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/lib/input_exports_Actions.html

Also found different example on web which support it should work, but cannot see what is missing in this basic example:

"use strict";
require('chromedriver');
const { Builder, By, Key, until, ActionSequence } = require('selenium-webdriver');
(async function run() {
    let driver = await new Builder().forBrowser('chrome').build();
    try {
        await driver.get('http://www.google.com');

        await driver
            .actions()
            .doubleClick(By.id('lst-ib'))
            .perform();
    }
    finally {
        await driver.quit();
    }
})();

Also tested in a project with protractor and it seem to work, but I don't see why I would need protractor in this project since it does not use Angular.

Thanks

Aucun commentaire:

Enregistrer un commentaire