Получите все дочерние элементы

В Селене с Python возможно получать всех детей WebElement как список?

61
задан 3 May 2018 в 17:03

1 ответ

Вот код для получения дочерних элементов (В Java):

String childTag = childElement.getTagName();
if(childTag.equals("html")) 
{
    return "/html[1]"+current;
}
WebElement parentElement = childElement.findElement(By.xpath("..")); 
List<WebElement> childrenElements = parentElement.findElements(By.xpath("*"));
int count = 0;
for(int i=0;i<childrenElements.size(); i++) 
{
    WebElement childrenElement = childrenElements.get(i);
    String childrenElementTag = childrenElement.getTagName();
    if(childTag.equals(childrenElementTag)) 
    {
        count++;
    }
 }
0
ответ дан 31 October 2019 в 15:35

Другие вопросы по тегам:

Похожие вопросы: