Navigate to a specific Selenium WebDriver Java element

Im using Seleniumwith Javaand ChromeDriverto run multiple scripts on a website. I want to scroll the driver or page to a specific item located on the page. It can be seen. I understand that with JavaScripExecutorMaybe, but so far, as I do this, I can only scroll through certain “spaces”. Here is what I have:

jse.executeScript("window.scrollBy(0,250)", "");
+4
source share
1 answer

If you want to go to a specific item, try using scrollIntoView(true)as shown below: -

//Find that specific element first 
WebElement element = driver.findElement(..);

//Now scroll to this element 
jse.executeScript("arguments[0].scrollIntoView(true);", element);
+1
source

Source: https://habr.com/ru/post/1652665/


All Articles