WebElement NumberofRecord = driver.findElement(By.xpath("//*[@id=\"tableContent\"]/div[2]/span/a"));
NumberofRecord.getText();
System.out.println(NumberofRecord);
试图获取文本但返回URL
结果:xpath:// * [@ id =“ tableContent”] / div [2] / span / a]
Expected Output: All 18418 Messages in Table are selected. Clear selection(this need to be displayed)
产生WebDriverWait
并等待visibilityOfElementLocated
(),然后获取文本值。
new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='tableContent']/div[2]/span/a")));
WebElement NumberofRecord = driver.findElement(By.xpath("//*[@id='tableContent']/div[2]/span/a"));
System.out.println(NumberofRecord.getText());