Discussion:
[nodejs] Unable to find solution ## Nodejs + Selenium
Shatabdi Pal
2018-04-26 06:51:27 UTC
Permalink
I am pretty new to nodejs, can someone help me please?

This is my code below::


var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().forBrowser('chrome').build();
driver.get('http://www.google.com');
driver.findElement({name: 'q'}).sendKeys('webdriverjs');
driver.findElement({name: 'q'}).sendKeys(webdriver.Key.ENTER);
driver.manage().window().maximize();
driver.wait(webdriver.until.elementLocated({xpath:
'//*[@id="rso"]/div/div/div[1]/div/div/h3/a'}), 30000);
driver.findElement({xpath:
'//*[@id="rso"]/div/div/div[1]/div/div/h3/a'}).click();

Getting the following error:

DevTools listening on
ws://127.0.0.1:12148/devtools/browser/86604bd8-c770-4659-bdaf-0abbf4cd790c
(node:15596) UnhandledPromiseRejectionWarning: NoSuchElementError: no
such element: Unable to locate element:
{"method":"xpath","selector":"//*[@id="rso"]/div/div/div[1]/div/div/h3/a"}
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.36.540470
(e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.16299
x86_64)
at Object.checkLegacyResponse
(C:\Users\SPal\webdriverjs\node_modules\selenium-webdriver\lib\error.js:585:15)
at parseHttpResponse
(C:\Users\SPal\webdriverjs\node_modules\selenium-webdriver\lib\http.js:533:13)
at Executor.execute
(C:\Users\SPal\webdriverjs\node_modules\selenium-webdriver\lib\http.js:468:26)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)
(node:15596) 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:15596) [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.
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/cc0bb2f6-6049-4a9a-8a11-59c832f627d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...