簡體   English   中英

如何捕獲 web 表中的特定列值

[英]How to capture specific column values in a web table

尋找一種解決方案來捕獲 web 表中的特定列值。 在捕獲的列值中計算 eg-pass 和 fail 的數量,然后打印每個狀態的計數。

在此處輸入圖像描述

我想直接 go 到這里的狀態列並獲取它下面的所有值。 然后想要計算每種狀態類型並打印。

你需要這樣的東西(如果我們談論的是 html 表):

   private List<WebElement> getTableRows(By by) {
        Validate.notNull(by, "Table element should not be null");
        List<WebElement> rows = driver.findElement(by).findElements(By.tagName("tr"));   // get table rows
        return rows;
    }

    protected String getCellValue(WebElement row, int columnIndex) {
        Validate.notNull(row, "Row element should not be null");
        String cell = "";
        cell = row.findElement(By.xpath("td[" + columnIndex + "]")).getText();  // get columns by index
        return cell;
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM