Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
354 views
in Technique[技术] by (71.8m points)

node.js - javascript selenium automaion no such element found, unable to locate element

I was trying for web automation for signing into my google account using selenium by javascript, but suddenly I was caught up by this error. It throws an error that no such element found. I had even tried by finding the element by its css selector, but no use it thrown me the same error, previously I had faced this error using python selenium automation, but there I fixed it, by using WebDriverWait() function. And now facing the same issue here in javascript.

How can I fix it. Any Help would be appreciated:)

This is my Code `

const {Builder, By, Key, util} = require('selenium-webdriver');
require('chromedriver');
async function example(){
    var link = "https://meet.google.com/"
    var link_join = "https://meet.google.com/nrz-cdwf-hwo"
    let driver = await new Builder().forBrowser("chrome").build();
    await driver.get(link);
    // Sign In...
    await driver.findElement(By.css('span.cta-wrapper:nth-child(1) > a:nth-child(1)')).click();
    //Email...
    await driver.findElement(By.css('#identifierId')).sendKeys('My email address');
    //Next btn...
    await driver.findElement(By.css('#identifierNext > div > button > div.VfPpkd-RLmnJb')).click();
    //Password...
    await driver.findElement(By.xpath('//*[@id="password"]/div[1]/div/div[1]/input')).sendKeys("My Password");  
    //elementLocated


}
    
example()

This is my console's output :

uday@uday-Aspire-A515-51G:~/Code/AutomateApp$ node index.js

(node:8533) UnhandledPromiseRejectionWarning: *NoSuchElementError: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="password"]/div[1]/div/div[1]/input"}*
  (Session info: chrome=87.0.4280.141)
    at Object.throwDecodedError (/home/uday/Code/AutomateApp/node_modules/selenium-webdriver/lib/error.js:517:15)
    at parseHttpResponse (/home/uday/Code/AutomateApp/node_modules/selenium-webdriver/lib/http.js:655:13)
    at Executor.execute (/home/uday/Code/AutomateApp/node_modules/selenium-webdriver/lib/http.js:581:28)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:8533) 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:8533) [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.

'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...