-1

I have a page with multiple sections(divs). In that only one div is scrollable, not the whole page. So I can scroll that particular div using Selenium? Javascript will also work if possible, so I will execute that script.

java.lang.NoSuchMethodError: org.apache.commons.logging.LogFactory

In this post, you can see 2nd part of the question(code) is scrollable so I want to scroll only that code part rather than the whole page.

Thank you

5
  • This question should include more details and clarify the problem. Commented Jun 19, 2021 at 19:46
  • @cruisepandey could you please updated the post. Commented Jun 20, 2021 at 3:56
  • What do you mean by update the POST ? Commented Jun 20, 2021 at 15:29
  • I meant to say that I have updated the description of my query. Please let me know if you need additional info. Commented Jun 20, 2021 at 16:32
  • @cruisepandey do you know how can we do this? Commented Jun 26, 2021 at 4:46

1 Answer 1

0

Through the selenium, I am not able to scroll. But through Javascript, I made one script and execute that script with JavascriptExecutor.

Sometimes script not running on the first try so try to put it into a loop and do retry.

JavascriptExecutor jse = (JavascriptExecutor) webDriver;
                
String js = "(document.evaluate('XPATH_OF_ELEMENT', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue).scrollBy(0,10000)";
                
System.out.println(js);

jse.executeScript(js);
Sign up to request clarification or add additional context in comments.

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.