使用webElement.text()方法获取字符串时,有时候会获取失败--获取到的内容为空

 

使用 webElement.getAttribute("attributeName"),通过textContentinnerTextinnerHTML等属性获取

public String getText(String string){
        WebDriverWait wait = new WebDriverWait(driver, 10);
        WebElement webElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(string)));
        return webElement.getAttribute("innerText");
    }

 

相关文章:

  • 2021-07-24
  • 2021-09-28
  • 2022-12-23
  • 2022-01-21
  • 2021-09-27
  • 2021-04-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-02
  • 2022-02-22
  • 2021-03-30
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
相关资源
相似解决方案