Answer the question
In order to leave comments, you need to log in
How to search for the xpath of an element in a new opened window?
I have a simple node.js program that goes to tinder and tries to login with facebook.
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
let driver = await new Builder()
.forBrowser("chrome")
.build();
// Google tinder
await driver.get("https://tinder.com/?lang=ru");
// Accept privacy polices
let policyBtnPath = "//*[@id=\"content\"]/div/div[2]/div/div/div[1]/button";
await driver.findElement(By.xpath(policyBtnPath))
.click();
// Waiting for login button and bush it
await sleep(3000);
let loginBtnPath = "//*[@id=\"modal-manager\"]/div/div/div/div/div[3]/span/button";
await driver.findElement(By.xpath(loginBtnPath))
.click();
// Login via Facebook
let facebookLoginPath = "//*[@id=\"modal-manager\"]/div/div/div/div/div[3]/span/div[2]/button";
await driver.findElement(By.xpath(facebookLoginPath))
.click();
// Waiting for login form
await sleep(4500);
// Enter login and password
let loginPath = "//*[@id=\"email\"]";
let passPath = "//*[@id=\"pass\"]";
await driver.findElement(By.xpath(loginPath))
.sendKeys(MY_MAIL);
(node:8402) UnhandledPromiseRejectionWarning: NoSuchElementError: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="email"]"}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question