1
votes

I'm trying to run a simple test with selenium without success.

I have a javascript config test:

chrome.config.js

var driver = new webdriver.Builder().
  .forBrowser('chrome')
  .build();


driver.get('http://www.google.com');

driver.findElement(By.name('btnI')).click();

I'm getting the following error:

(node:5921) UnhandledPromiseRejectionWarning: WebDriverError: element not interactable (Session info: chrome=70.0.3538.77) (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-42-generic x86_64) at Object.checkLegacyResponse (/home/pablo/workspace/bricks-editor/node_modules/selenium-webdriver/lib/error.js:585:15) at parseHttpResponse (/home/pablo/workspace/bricks-editor/node_modules/selenium-webdriver/lib/http.js:533:13) at Executor.execute (/home/pablo/workspace/bricks-editor/node_modules/selenium-webdriver/lib/http.js:468:26) at at process._tickCallback (internal/process/next_tick.js:188:7) (node:5921) 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: 1) (node:5921) [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.

What can be wrong here?

My settings:

node version: 8.11.3

chromedriver version: 2.44.609551

OS: Ubuntu 18.0.4 LTS 64 bits

2

2 Answers

1
votes

After some tests, I was able to do my code work with the following changes.

var webdriver = require('selenium-webdriver'),
  By = webdriver.By,
  until = webdriver.until;

var driver = new webdriver.Builder()
  .forBrowser('chrome')
  .build();


driver.get('http://www.google.com');

var btnI;

driver.findElements(By.name('btnI')).then(function(list) {
  btnI = list[1];
  btnI.click();
});
1
votes

There are two input fields with the same @name: the first one is hidden. You need to handle the second (visible) one:

driver.findElement(By.cssSelector('div.FPdoLc input[name="btnI"]')).click();