-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learning Selenium Testing Tools - Third Edition - Third Edition
By :
We have had a look at using helper methods to find elements on the page. The downside to this is that, if something changes, you need to change the entire method that you are using to find the element. This can increase maintenance costs.
The other approach is to use the findElement() method, pass in the By abstract class, and call static methods on this class.
Let's see this in action.
In this section, we will look at using the findElement call that is on the WebDriver object. This is how we normally find elements using Selenium WebDriver:
driver.get("http://book.theautomatedtester.co.uk")
driver.findElement(By.linkText("Chapter1"));We have just seen that we can find an element by passing in the By object. This is a static class that gives people a mechanism to find elements, as we did earlier in the chapter. This will throw NoSuchElementException...
Change the font size
Change margin width
Change background colour