Scrolling on pop up with javascript executor or selenium?


I am new with web automation, currently using Selenium to learn automation web

I have a case where I need to scroll down to the bottom after select one of the available menu and set the value

Here is the pop up window

enter image description here

I am able to select item on the top but unable to click on the left side to scroll down after set Brand and I want to select Seller at the bottom of the left panel.
I try with javascript executor and got an null pointer, with press key PAGE_DOWN not working for me


In such cases you need to scroll down the scrollable element containing that list of selectable options, not scrolling the entire web page.
You did not share a link to the web page you are working on and not a language you are coding with, so I can’t give you a precise solution.
Working with Java I use the following method:

public void scrollOnElement(String css){
    JavascriptExecutor jsExec = (JavascriptExecutor) driver;
    String script = stringFormat("document.querySelector('%s').scrollDown += 250",css);

here css is a css selector for the container element I want to scroll.
Also, in your case possibly you will have to use something more smart than hardcoded 250 pixels for the scrolling height.
The left vertical scrollable element css locator is ‘#c3-mainPanel’ so I think the following code should work in Python:

left_vertical_scrollable_css = "#c3-mainPanel"
left_vertical_scrollable = driver.find_element_by_css_selector(left_vertical_scrollable_css)
driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", left_vertical_scrollable)

Answered By – Prophet

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published