首页 > Web开发 > 详细

webElement.text()获取到内容为空

时间:2019-01-21 13:28:50      阅读:477      评论:0      收藏:0      [点我收藏+]

使用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");
    }

 

webElement.text()获取到内容为空

原文:https://www.cnblogs.com/lozz/p/10297977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!