如何使用webdriver获取元素的所有后代? [英] How to get all descendants of an element using webdriver?

查看:1204
本文介绍了如何使用webdriver获取元素的所有后代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这个元素有子元素,那些子元素又有子元素等等。我想获得元素的后代的所有元素。感谢。

解决方案

尝试这个:



  List< WebElement> childs = rootWebElement.findElements(By.xpath(.//*)); 

(C#)

  IReadOnlyList< IWebElement> childs = rootWebElement.FindElements(By.XPath(.//*)); 


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.

解决方案

Try this one:

(Java)

List<WebElement> childs = rootWebElement.findElements(By.xpath(".//*"));

(C#)

IReadOnlyList<IWebElement> childs = rootWebElement.FindElements(By.XPath(".//*"));

这篇关于如何使用webdriver获取元素的所有后代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆