无法打印网页表内容

我正在打印一些Web表格内容,而我正在打印以下输出的内容。 (网络驱动程序crome xp)

代码:

    WebDriver driver = DriverFactory.getWebDriver()
    // simplified: find table which contains the keyword
    WebElement tableElement = driver.findElement(By.xpath("/html/body/div[4]/div/main/div/div[3]/div[2]/div/div[1]/div[4]/div[2]/table"));

    // create empty table object and iterate through all rows of the found table element
    ArrayList<HashMap<String,WebElement>> userTable = new ArrayList<HashMap<String,WebElement>>();
    ArrayList<WebElement> rowElements = tableElement.findElements(By.xpath(".//tr"));

    // get column names of table from table headers
    ArrayList<String> columnNames = new ArrayList<String>();
    ArrayList<WebElement> headerElements = rowElements.get(0).findElements(By.xpath(".//th"));
    for (WebElement headerElement: headerElements) {
      columnNames.add(headerElement.getText());
    }

    // iterate through all rows and add their content to table array
    for (WebElement rowElement: rowElements) {
      HashMap<String,WebElement> row = new HashMap<String,WebElement>();

      // add table cells to current row
      int columnIndex = 0;
      ArrayList<WebElement> cellElements = rowElement.findElements(By.xpath(".//td"));
      for (WebElement cellElement: cellElements) {
        row.put(columnNames.get(columnIndex),cellElement);
        columnIndex++;
      }


  userTable.add(row);
  println userTable
}

输出

无法打印网页表内容

budianxyl 回答:无法打印网页表内容

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3139771.html

大家都在问