0

I need to scroll down, but the problem is the scrolling is not applied in whole page its only a table body.

i tried Set_focus_on_element and move_over to the table and then tried scrolling but it didnt work.

to scroll till the element is located i used

Execute Javascript   window.document.evaluate("${xpath}", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.scrollIntoView(true)

This seems to work fine on other places but to scroll only Table body, first i need to set focus there, but no luck so far

1
  • Really!!! no answers.. :(' Commented Jul 9, 2018 at 4:58

2 Answers 2

2

I tried with Java and javascript everything is working fine. Hope for you it would also work.

First get the webelement:

WebElement we = driver.findelement(By.xpath("your xpath")) // make sure it should present on DOM, if it not them need to move scroll down or scroll up then again try to find the webElement.

if you get the webelement then use below code:

JavascriptExecutor jse = (JavascriptExecutor) driver;

driver.executeScript("arguments[0].scrollIntoView(true);", we);

For scroll down:

jse.executeScript("window.scrollBy(0,document.body.scrollHeight || document.documentElement.scrollHeight)", "");

For scroll Up:

jse.executeScript("window.scrollBy(0,-document.body.scrollHeight || -document.documentElement.scrollHeight)", "");

Height can be adjusted according to your need like:

jse.executeScript("window.scrollBy(0,(-document.body.scrollHeight)/4 || -(document.documentElement.scrollHeight)/4)", "");
Sign up to request clarification or add additional context in comments.

2 Comments

I guess you are scrolling on whole page. I need to scroll only on a scroll-able table till the element in the table is found and table is in the actual website
I mentioned all the options. First option you can use to scroll to your table.
-1

swipe left move to right in the table view code sleep 1 Swipe x y(constant) x y(constant)

example sleep 1 Swipe .8 564 .3 564

make sure you will gives y coordinate where the table view is present. so that you can easily scroll in

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.