How to extract dynamic text from multiple child nodes within the html through getText()

前端 未结 2 1741
轮回少年
轮回少年 2020-12-12 00:56

We have a Div containing some hard coded text and span containing some dynamic text values (refer below HTML code for more understanding). The resultant Text is: 1

2条回答
  •  星月不相逢
    2020-12-12 01:18

    Before you attempt to extract the total text e.g. 1 Tasks to be updated from 'XYZ' to 'ABC' you can induce WebDriverWait for all the three child elements to be visible and you can use the following solution:

    new WebDriverWait(driver, 10).until(ExpectedConditions.and(
        ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@id='taskCountSpan']")),
        ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@id='oldStatusSpan']")),
        ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@id='newStatusSpan']"))
    ));
    

提交回复
热议问题