课程: Test Automation with Selenium WebDriver for Java

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Navigation

Navigation

- Browsers have built-in capabilities that allow you to navigate through web pages. For example, after navigating to other pages, we can use these arrows to go back and forward. There's also a button to refresh. With Selenium WebDriver, we can accomplish these same browser actions even though those buttons aren't represented in the DOM of the page. Let's see how. The code we have here goes to the clicks page and clicks a link to bring us to a new page. Now we'll go to the previous page by saying driver.navigate().back(); and we'll print out where we are now, so let's do a print statement and say we went back. We're now on page, and we can add the title of the page here, so driver.getTitle(); Now we'll go forward by saying driver.navigate().forward(); and we'll also print where we are now, "went forward. on page: " and we'll add the title again. Great. Now let's run this. Awesome. We see that we started on the clicks page. We clicked the link, which brought us to the XHTML test page…

内容