如何使用 webdriver 获取元素的所有后代? [英] How to get all descendants of an element using webdriver?
本文介绍了如何使用 webdriver 获取元素的所有后代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有这个元素有子元素,那些子元素又有子元素等等.我想获得所有元素的后代元素.谢谢.
There is this element which has child elements, those child elements again have child elements and so on. I would like to get all elements that are descendants of the element. Thanks.
推荐答案
试试这个:
(Java)
List<WebElement> childs = rootWebElement.findElements(By.xpath(".//*"));
(C#)
IReadOnlyList<IWebElement> childs = rootWebElement.FindElements(By.XPath(".//*"));
这篇关于如何使用 webdriver 获取元素的所有后代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文