如何在单行和多列中传递值

how to pass value in single row and multiple column

我需要处理 webtable 以传递值特定列 as here。

 String p=" Ease 3.0   | 9";
 WebElement Product=driver.findElement(By.xpath("//h1[text()='"+p+"']//parent::div//following-sibling::div[1]//div[1]//div[2]"));

 WebElement findp=Product.findElement(By.tagName("tbody"));

 List<WebElement> great=findp.findElements(By.xpath("tr"));

 int rowcount=great.size();

 System.out.println(rowcount);

 for(int i=0;i<=great.size();i++)
 {
        XSSFRow foundRow =sheet.getRow(i);

        List<WebElement> column_row=great.get(i).findElements(By.tagName("td"));
        int columncount=column_row.size();

        System.out.println("total number of row"+rowcount+"columns are"+columncount);
}

但我收到以下错误。请任何人帮忙。

FAILED: Allproduct java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source)

您正在尝试访问超出列表范围的索引。

for(int i=0;i<=great.size();i++)

您正在检查 i 是否小于或等于列表的大小,但这是错误的。

假设列表有 3 个元素[1,2,3]。计数将为 return 3,但最后一个元素的索引为 2(从零开始)。当您尝试访问索引 3 时,将抛出异常。