Scroll in dropdown triggers scroll on the main page

Hi everyone,

I am encountering an issue during testing.
I cannot manage to scroll down in a dropdown.

The flow is the following:

  • click a field
  • a dropdown is shown on the page
  • now, in order for me to select the value that I need I must scroll in the dropdown.

I have tried the scroll to element method but it would scroll the main page instead of the dropdown.
The code_x locator is a variable that goes in a test data file to pick the values that I want to select in the dropdown.

Thanks for you help.

If you right click on one of the drop-down contents (like on “FM02b_10”) and select Inspect, does the HTML look like a column of similar element types? In other words, can you collect a list of web elements (List<WebElement> ) and then move through the list of elements like they were a “table” and choose one this way. It may mean to “loop” through the “table” comparing the items to your “pick”.


Does anyone have a different approach for handling the issue?

Thanks :slight_smile:

In essence, @grylion54 has given you a pretty clear method to approach this problem. Instead of just ignoring what’s been said, can you explain why it didn’t work for you?

My approach would be something like…

  1. Using JavaScript…
  2. Make the dropdown appear
  3. Call the Web API scrollIntoView() on the element I need to see
  4. Click the element.

Hi Russ,

I did not ignore the answer, I am working on it.
I was just curious for other approaches.

I highly appreciate the answer.

Hi Russ,

I am working on the approach you described me above, however I still do not see the scroll in the dropdown functioning.
I guess I am still missing something related to the scriollIntoView function.

Found the solution,

I had to change the value of the scrollIntoView function to “false”.


1 Like

Interesting. I’ve only ever used the default, true.

Good you got it working :slight_smile: