簡體   English   中英

Selenium Webdriver [Java]動態表:獲取行的最后一個值(帶條件)

[英]Selenium Webdriver [Java] Dynamic Table: Get the last value of a row (With Conditionals)

我需要將Selenium與動態表配合使用的幫助。

我需要單擊狀態為“ ACTIVE”的LAST帳戶。在該圖像中顯示了該示例。

動態表

我正在嘗試下一個代碼:

WebElement lastCredit = driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr[last()]/td[3]/a and contains(text(), 'ACTIVE'") );
lastCredit.sendKeys(Keys.ENTER);

我無法單擊accound,該程序失敗。

我正在嘗試使用2 FOR:

    WebElement rows = driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr"));
    List<WebElement> columns = (List<WebElement>) driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr[1]/td"));
    String[] array = new String[4];


    for(int i = 0; i <= rows.length; i = i ++)
    {
      for(int j = 0; j <= columns.length; j = j ++)
      {     
        array[j] = driver.findElement(By.xpath("(//table[@class='tableinfo']/tbody/tr[i]/td[j]/a")).getAttribute("value");
      }

      if (array[4] == “ACTIVE”) and (array[4].last()); {

          array.get(4).click();
}
    }

請幫我。

無論圖片是什么,如果您的要求是單擊最后一個活動狀態,請嘗試以下簡單代碼段

List<WebElement> activeColumns = driver.findElements(By.xpath("//td[text()='ACTIVE']"));
activeColumns.get(activeColumns.size()-1).click();

暫無
暫無

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

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