Selenium web driver: cannot be scrolled into view Selenium web driver: cannot be scrolled into view selenium selenium

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 secondswait.until(ExpectedConditions.visibilityOf(element)); //this will wait for elememt to be visible for 20 secondselement.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);


Try to execute the script and click the element

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


I'm not sure but try and see if following works for you. First, you've to make that element visible before interacting with it -

WebElement element = driver.findElement(By.xpath("//div[2]/div[2]"));((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

The above code will scroll down till the element is visible and then you can click on it.