Yo dawg I heard you like web elements...
So I would like to know if it is possible to find a web element by class, id or any other selector and then inside that find another element by class etc.
Background
I have some container with an id that contains a collection of elements I want to put into a list by class, the problem is that if I try to getElements(By.class)
it will pick up some elements outside that I don't want.
Attempted
I have tried doing it with XPATH
but it feels dirty like hard coding. Since these tests should be robust I thought there must be a better way of doing it.
This code captures elements outside of what I want
public double checkStars(){
List<WebElement> starsOn = driver.findElements(By.className("on"));
return starsOn.size();
}
Question
Can I select a web element when limiting the search to inside another web element and how is it done?
Aucun commentaire:
Enregistrer un commentaire