Locating child nodes of WebElements in selenium

前端 未结 5 2069
谎友^
谎友^ 2020-11-29 03:13

I am using selenium to test my web application and I can successfully find tags using By.xpath. However now and then I need to find child nodes within that node

5条回答
  •  臣服心动
    2020-11-29 03:28

    If you have to wait there is a method presenceOfNestedElementLocatedBy that takes the "parent" element and a locator, e.g. a By.xpath:

    WebElement subNode = new WebDriverWait(driver,10).until(
        ExpectedConditions.presenceOfNestedElementLocatedBy(
            divA, By.xpath(".//div/span")
        )
    );
    

提交回复
热议问题