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());