Book Image

Learning Selenium Testing Tools - Third Edition

Book Image

Learning Selenium Testing Tools - Third Edition

Overview of this book

Table of Contents (22 chapters)
Learning Selenium Testing Tools Third Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using findElement Helper methods


Let's try to create an example where you need to find an element using the CSS selector. This is used by findElementByCssSelector and findElementsByCssSelector.

For example,

using indElementByCssSelector:

Driver.get("http://book.theautomatedtester.co.uk")
WebElement element = ((FindsByCssSelector)driver).findElementByCssSelector("Chapter1");

using findElementsByCssSelector:

driver.get("http://book.theautomatedtester.co.uk")
List<WebElement> elements = ((FindsByCssSelector)driver).findElementsByCssSelector("Chapter1");
Assert.equals(1, elements.size());