I want to match the RFQ No passed in string with some data in table and when this matches with particular row I want to click button in that matched row but at some other column
But code is giving error
Code :
String baseUrl = "https://test.transporteg.com/";
driver.get(baseUrl);
driver.findElement(By.xpath("//*[@id=\"j_idt12:email\"]")).sendKeys("kevin@openspaceservices.com");
driver.findElement(By.xpath("//*[@id=\"j_idt12:password\"]")).sendKeys("Eg123");
driver.findElement(By.xpath("//*[@id=\"j_idt12:j_idt19\"]")).click();
driver.findElement(By.linkText("Dashboard Provider")).click();
driver.findElement(By.xpath("//*[@id=\"rfqViewId:j_idt248_data\"]/tr/td[5]/div[1]/input")).click();
WebElement Webtable = driver.findElement(By.xpath("//*[@id=\"table-1\"]/tbody/tr[1]/td[1]"));
List<WebElement> allElements = Webtable.findElements(By.xpath("//*[@id=\"table-1\"]/tbody/tr/td[1]"));
System.out.println("Reached Here 1");
System.out.println("No. of Rows in the WebTable: " + allElements.size());
String[] RFQ_NO = {"6291/91/06/18"};
System.out.println("Reached Here 8");
System.out.println("All emelements count "+allElements.size());
for (WebElement we : allElements) {
for (int i = 0; i <= allElements.size(); i++)
{
System.out.println("For loop Count"+i);
if (we.getText().equals(RFQ_NO[i])) {
System.out.println("Matched at Row"+(i));
driver.findElement(By.xpath("//*[@id=\"table-1\"]/tbody/tr[" + (i + 1) + "]/td[7]/a/img"))
.click();
// *[@id="table-1"]/tbody/tr[2]/td[7]/a/img
} else {
System.out.println("Not Matched");
}
}
}
}
}
Error :
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at ListPackage.List_Class.main(List_Class.java:86)
Can you please help.