jQuery scroll to element
When you manually test something at the bottom of the page first you need to Scroll and second you start interacting with your Element , so does selenium. By default selenium actively scrolls to the element that needs to perform actions but you might end up having issues most of them happen on Firefox but even in Google chrome. So in this situation you need a stable method to scroll to the element and after perform the next selenium action that you want.
I will provide the code in ruby using Capybara but you can easily adapt it to any other programming languages.
So what is a root_element?
The css selector that is passed as the 3rd argument to the
sections method (“#results li”) is used to find a number of capybara elements. Each capybara element found using the css selector is used to create a new instance of the
SearchResultSection and becomes its root element. So if the css selector finds 3
li elements, ccalling
search_results will return an array containing 3 instances of
SearchResultSection, each with one of the
lielements as it’s root element.
If you are wandering about root_element , you can consult site prism git hub page for more details .
You can enjoy reading a pair of articles part of the selenium tips bunch: Capybara get attribute or Tellurium selenium .
Happy testing people!
The post Jquery Scroll to element appeared first on TestingRepository.