如何使用 Xpath selenium java 从 Ngx 数据 table 获取文本
how to get text from Ngx data table using Xpath selenium java
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());
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());