In order to interact with elements on the page, you need to select those elements within your Selenium scripts.
A problem we see frequently is users reporting that tests against Android devices return an error, “could not find element”. This is due to the model that Android uses for the DOM within Selenium – an object does not appear to Selenium’s DOM unless it is visible within the viewport of the browser on the Android device. While this issue does not impact other devices or browsers, it can make testing against Android devices quite difficult.
Fortunately, there is a workaround for this issue.
In the above example, we scroll to
Scrolling by a set distance
In the above example, we use the
window.scrollBy() method to scroll down by 300 pixels (0 pixels horizontally, 300 pixels vertically). Using a command like this, it is possible to scroll until the element is visible, by testing for the element’s visibility and scrolling further down if it is not visible.
As always, if you have any other questions, concerns, or comments, feel free to reach out to us at any time, either using our in-app chat function, or emailing us at email@example.com.