课程: Test Automation with Selenium WebDriver for Java
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Scroll
- [Instructor] Oftentimes webpages require you to scroll in order to see all of its content. Let's use WebDriver to scroll to line9 in this list. We first locate the element, so we can say VAR line9 equals driver.findelement and we'll do by.id, and the idea of that element is line9. Then we use the actions class to scroll to the element, so let's say new actions, driver.scrolltoelements, and we pass in the line9 elements and then we call perform to trigger the action. Let's run this script in debug mode so we can see the action occur. We'll put a break point on the actions line. To run in debug mode, click debug above the main method and we'll switch over to our virtual box. When the page launches, we see that line9 is not in view. However, when we scroll to element and check again, notice that we see the action has been performed. One thing to note about scrolling is that for most interactions it's not required. For example, if you wanted to click line9, it doesn't need to be in view…