我试图重复一个循环,但添加标签没有帮助。我已经提到了基本代码,我想要显示,直到下一页可用

时间:2015-08-15 18:23:01

标签: selenium-webdriver

我正在尝试重复一个循环,但添加标签没有帮助。我已经提到了基本代码,我希望显示到下一页可用。

如下所述,在点击nextPage之后,我希望增加g的计数,并获得所有Table内容。请帮助。

public void GetTableData(String TableRowXpath,WebDriver driver) throws InterruptedException, InvalidFormatException, IOException{
      WebElement nextPage=driver.findElement(By.xpath("//a[@id='ldtable_next' and @class='paginate_button next']"));
      //WebElement nextPageNotAvailable=driver.findElement(By.xpath("//a[@id='ldtable_next' and @class='paginate_button next disabled']"));
      int g=1;
      if(nextPage.isDisplayed()){
          List<WebElement> Rowlist=driver.findElements(By.xpath(TableRowXpath));

          int RowIndex=1;

          for(WebElement rowElement:Rowlist)
          {
              List<WebElement> columnlist=rowElement.findElements(By.xpath("td"));
              int ColumnIndex=1;
              int h=0;
              for(WebElement colElement:columnlist)
              {
                  System.out.println("Row "+RowIndex+" Column "+ColumnIndex+" Data "
                  + colElement.getText());
                  String j=colElement.getText();
                  ExcelLib e=new ExcelLib();
                  e.createRow("Sheet3", h); 
                  e.setExcelData("Sheet3",h, g, j);
                  ColumnIndex=ColumnIndex+1;
                  h++;
              }
              g++;
              RowIndex=RowIndex+1;
          }
         nextPage.click();
         Thread.sleep(5000);     
      }        
  }

1 个答案:

答案 0 :(得分:0)

下面的代码可用于获取表数据  public void GetTableData(String TableRowXpath,WebDriver driver)抛出InterruptedException,InvalidFormatException,IOException {

RPAD

}