Chapter 4. Finding Elements
In this chapter, we will look at how to find elements on the page using the WebDriver API. One of the things that we learned in the previous chapter was that WebDriver and its architecture have a major component called driver. This has the commands to find elements.
Let's start with the different commands. We begin with the helper commands and then move on to the more generic commands, which take different types of objects. We will finish the chapter with some helpful techniques when interacting with element finding.
Two major learning points are as follows:
- Finding elements on the page by their ID, name, ClassName, XPath, and link list
- Tips to use find element calls
So let's get on with it. When working with the following examples, we are going to assume that you have instantiated a WebDriver object by using the following code:
WebDriver driver = new FirefoxDriver();
You can use the following example class with TestNG. The test is a stub that...