This example WebDriver test uses the PageObject pattern (via PageFactory). The test does the following:
- Opens a Chrome browser
- Navigates to [ask.com]
- Searches for the term "tidemark"
- Grabs all the results in the main section and prints out the link, associated title and description. The information is stored in a collection. The test then asserts that only 10 results are returned.
- Using the navigation at the bottom of the page, goes to the "Next" page.
- Then grabs all results in the main section and prints out the links, associated title and descriptions. The information in a collection and assert that only 10 links are returned.
- From all the descriptions that were stored previously, count the number of times "tidemark" string appears. Print this number.
To run using Maven command-line:
$ mvn integration-test
- Open Run > Run Configurations...
- Right-click on "TestNG" and select "New"
- Select "Suite" and check the box for "testng.xml"
- Click Save
- Click Run