Selenium web driver: cannot be scrolled into view

Naif,

Actually, your above question is different than the actual question hence you should have asked it as a separate question. Still, I’m answering to your previous question.

The error is because the element you’re trying to click on isn’t visible. Before you click on element, it should be visible. You can do this by following –

WebElement element = driver.findElement(By.xpath("//div[2]/div[2]"));
WebDriverWait wait = new WebDriverWait(driver, 20); //here, wait time is 20 seconds

wait.until(ExpectedConditions.visibilityOf(element)); //this will wait for elememt to be visible for 20 seconds
element.click(); //now it clicks on element

If above doesn’t work, you can click on element by executing javascript(but this isn’t a good practice)

JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);

Leave a Comment