Reputation: 1
In Telerik it’s possible to search elements within an element that was already found. E.g. I found an ul, that has some elements li. After that I can invoke find() directly from the element.
Is there such possibility using the WebDriver Java?
Upvotes: 0
Views: 296
Reputation: 1251
Actually, you can use
List<WebElement> = driver.findElements(By.cssSelector(".ul li"));
Your list contains all li elements who are in the ul.
Upvotes: 0
Reputation: 18455
In WebDriver the usual way of finding an element on the page is;
WebElement element = driver.findElement(By.xpath("xpath query here"));
The findElement
method is provided by SearchContext
inferface, which WebElement
also extends. This means you can call findElement
on any element found by a previous search;
WebElement child = element.findElement(By.xpath("another xpath query"));
Upvotes: 3