Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am using Java and Selenium to write a test. the target application has some inner pages, and I need to scroll to top of a web element in one the pages. I used:
jse.executeScript("arguments[0].scrollTop", element);
but it did not work, I also used scrollIntoView
but it did not work as the element is covered by another element.
–
Make the element in the foreground invisible, then use scrollIntoView().
...Something like jse.executeScript('arguments[0].style.visibility="hidden"', element)
?
My Python solution, it should translate easily:
def makeInvisible(driver, element):
driver.execute_script('arguments[0].style.visibility="hidden"', element)
I usually get the element by xpath and then pass it to that function. You can also double-check if something is hidden with an equivalent for:
def isInvisible(driver, element):
return driver.execute_script('return window.getComputedStyle(arguments[0]).display === \'none\'', element)
And of course write a function to make an element visible again with the above.
Hope that helps!
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.