I have an application that has worked correctly so far when logging in web form.
For several days there is an error that it cannot see the email item field: no such element: Unable to locate element: {"method": "css selector", "selector": "* [data-test =" email-input "]"}
I can't see any changes to this field name and can't find a solution to the problem.
My code snippet:
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
String actualUrl = "https://www.zocdoc.com/signin?provider=1";
driver.get(actualUrl);
try {
WebDriverWait waiter = new WebDriverWait(driver, 20);
waiter.until(ExpectedConditions.visibilityOf(driver.findElement(By.cssSelector("*[data-test=\"email-input\"]"))));
waiter.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("*[data-test=\"email-input\"]")));
log.info("element email-input found");
} catch (NoSuchElementException e) {
log.error("element email-input not found"); // this prints in log
}
driver.findElement(By.cssSelector("*[data-test=\"email-input\"]")).clear();
driver.findElement(By.cssSelector("*[data-test=\"email-input\"]")).sendKeys("email@some.com");
driver.findElement(By.cssSelector("*[data-test=\"password-input\"]")).sendKeys("password");
driver.findElement(By.cssSelector("*[data-test=\"sign-in-form-submit\"]")).click();
do you know what is teh reason ? regards
edit: i also tried:
driver.findElement(By.xpath("/html/body/div/div/main/span/div/div/div/div/div/div/form/label[1]/div[2]/input")).sendKeys("email@some.com");
driver.findElement(By.cssSelector(".label:nth-child(1) > div.textbox__TextboxWrapper-brYYtk.jscnkz > input")).sendKeys("email@some.com");
driver.findElement(By.xpath("//*[@id="main"]/div/main/span/div/div/div/div/div/div/form/label[1]/div[2]/input")).sendKeys("email@some.com");
and it does not work too.
edit: it's resolved. the cause of the problem is the service protection by WAF:
Selenium scraper detected at loading first page
I got around this problem, added some parameters to my java bot and now incapsula cant detect this bot.