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

使用 webElement.getAttribute("attributeName"),通过textContent, innerText, innerHTML等属性获取
public String getText(String string){WebDriverWait wait = new WebDriverWait(driver, 10);WebElement webElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(string)));return webElement.getAttribute("innerText");}



















