Selenium WebDriver getText

后端 未结 8 2091
广开言路
广开言路 2021-01-06 21:07

I have a

0
.

I try to write a test that myDiv has 0 text in it. With WebDriver it is:

<
8条回答
  •  执笔经年
    2021-01-06 21:32

    You can try using the jsoup library for parsing HTML.

    First just load the page content (driver.getPageSource()) to the jsoup document object and use the richness of methods of that excellent library (kudos to the author).

    Example:

    String pageSource = driver.getPageSource();
    Document doc = Jsoup.parse(pageSource);
    Elements requestsListRecords = doc.getElementsByTag("table").get(2).getElementsByTag("tr");
    

提交回复
热议问题