How to get all descendants of an element using webdriver?

后端 未结 3 2026
你的背包
你的背包 2020-12-07 23:09

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 elemen

相关标签:
3条回答
  • Try this one:

    (Java)

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

    (C#)

    IReadOnlyList<IWebElement> childs = rootWebElement.FindElements(By.XPath(".//*"));
    
    0 讨论(0)
  • 2020-12-07 23:34

    Try this one:

    List<WebElement> childs = rootWebElement.findElements(By.tagName(".//*"));
    
    0 讨论(0)
  • 2020-12-07 23:46

    Try this one

    List<WebElement> allDescendantsChilds = rootWebElement.findElements(By.xpath("//tr[@class='parent']//*"));
    

    The above thing will gives you all descendant child elements (not only immediate child) of parent tr

    0 讨论(0)
提交回复
热议问题