nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.83k stars 1.32k forks source link

After update of chromedriver, .keys doesn't work #2174

Closed Samuelfaure closed 4 years ago

Samuelfaure commented 5 years ago

Node 10.16.2 Chromedriver 76 (updated from 2.46) @vue/cli-plugin-e2e-nightwatch 3.10 (updated from 3.8)

This passed before :

  "Press enter launch search": function(browser) {
    browser
      .url(browser.launch_url)
      .waitForElementVisible("body")
      .setValue("input[name=search]", "coca-cola")
      .keys(browser.Keys.ENTER)
      .assert.urlEquals(
        browser.launch_url + "search?fullText=coca-cola&page=1"
      );
    browser.end();
  },

After upgrade, doesn't pass. This pass :

  "Press enter launch search": function(browser) {
    browser
      .url(browser.launch_url)
      .waitForElementVisible("body")
      .setValue("input[name=search]", ["coca-cola", browser.Keys.ENTER])
      .assert.urlEquals(
        browser.launch_url + "search?fullText=coca-cola&page=1"
      );
    browser.end();
  },

Checking the logs, I see an error :

INFO Request: POST /wd/hub/session/96753c5c576ae628a9fe3321faf345ce/keys 
 - data:  {"value":["\ue007"]} 
 - headers:  {"Content-Type":"application/json; charset=utf-8","Content-Length":20}
ERROR Response 500 POST /wd/hub/session/96753c5c576ae628a9fe3321faf345ce/keys (15ms) { value:
   { message:
      'sendKeysToActiveElement\nBuild info: version: \'3.141.59\', revision: \'e82be7d358\', time: \'2018-11-14T08:25:53\'\nSystem info: host: \'thinkplume\', ip: \'127.0.1.1\', os.name: \'Linux\', os.arch: \'amd64\', os.version: \'5.2.6-arch1-1-ARCH\', java.version: \'1.8.0_222\'\nDriver info: driver.version: unknown',
     error: 'unknown command' },
  status: 9 }
LOG     → Completed command keys (16 ms)

My nightwatch.conf.js :

require("@babel/register")();

// http://nightwatchjs.org/gettingstarted#settings-file

const deepmerge = require("deepmerge");
const userOptions = JSON.parse(process.env.VUE_NIGHTWATCH_USER_OPTIONS || "{}");

module.exports = deepmerge(
  {
    src_folders: ["tests/e2e/specs"],
    output_folder: "tests/e2e/reports",
    custom_assertions_path: ["tests/e2e/custom-assertions"],

    selenium: {
      start_process: true,
      server_path: require("selenium-server").path,
      host: "127.0.0.1",
      port: 4444,
      cli_args: {
        "webdriver.chrome.driver": require("chromedriver").path
      }
    },

    test_settings: {
      default: {
        selenium_port: 4444,
        selenium_host: "localhost",
        silent: true,
        test_workers: true,
        desiredCapabilities: {
          browserName: "chrome",
          javascriptEnabled: true,
          acceptSslCerts: true
        },
        // Base too big to be imported right now
        // launch_url: "http://localhost:8080/"
        launch_url: "https://sandbox.entreprise.data.gouv.fr/",
        globals: {
          // 15 seconds timeout for devs with slow connection / computer
          waitForConditionTimeout: 15000
        }
      },
      production: {
        launch_url: "https://entreprise.data.gouv.fr/"
      },
      sandbox: {
        launch_url: "https://sandbox.entreprise.data.gouv.fr/"
      },
      travis: {
        test_workers: false,
        launch_url: "https://sandbox.entreprise.data.gouv.fr/"
      }
    }
  },
  userOptions
);
ventil8 commented 5 years ago

Any update on this? I am seeing similar issue around the session...

vlad-vinogradov commented 5 years ago

as workaround:

try

.setValue("input[name=search]", "coca-cola" + browser.Keys.ENTER)

or use the following settings:

webdriver: { use_legacy_jsonwire: true },
desiredCapabilities: {
   'goog:chromeOptions': { w3c: false },
   ...
}
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any recent activity. If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.

tejasshekokar commented 4 years ago

I'm also facing the same issue on browser.keys(browser.Keys.ENTER). Any update on this?

cskubatz commented 4 years ago

I am also facing this issue. The command browser.keys(browser.Keys.RETURN); did not work. In nightwatch verbose mode i just see → Running command: keys ('') → Completed command: keys ('') (1ms) and got no error output. I am using "chromedriver": "78.0.1", "nightwatch": "1.3.1" and "chrome": "78.0.3904.108".

rankida commented 4 years ago

I also see this issue but it looks like it might have just been fixed: https://github.com/nightwatchjs/nightwatch/issues/2262#event-2857336184

cskubatz commented 4 years ago

After updating to NW 1.3.2 the problem is solved.

Changelog excerpt: Fixed #2262 - keys() command stopped working due to a regression

Thanks for fixing the issue! 👍

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had any recent activity. If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.

rahulb3521 commented 2 years ago

as workaround:

try

.setValue("input[name=search]", "coca-cola" + browser.Keys.ENTER)

Thank you this workaround was very useful