In the gridview I click the anchor tag in column KU_Total Qty following which I navigate to Grid in another page.
WebElement totalQty = ldriver.findElement(By.xpath("//td[@aria-describedby='jqTable_KU_Total Qty']/a[text()="+ qty + "]"));
totalQty.click();
I click on back arrow button to navigate to original page
WebElement backButton = ldriver.findElement(By.xpath("//li/a[@id='lnkBack']"));
backButton.click();
after which I'm not able to identify the KU_Total Qty located in next row giving no such element exception.
Below is the code
public void housingGridTotalQtyClick() throws Exception {
WebDriverWait wait = new WebDriverWait(ldriver, 20);
WebElement grid = wait.until(
ExpectedConditions.visibilityOfElementLocated(By.id("gview_jqTable_KU")));
grid = ldriver.findElement(By.xpath("//*[@id='gview_jqTable_KU']"));
Thread.sleep(2000);
List<WebElement> KUList = grid.findElements(By.xpath("//td[@aria-describedby='jqTable_KU_Total Qty']"));
List<String> totalQtyList = new ArrayList<String>();
for(WebElement KU: KUList) {
totalQtyList.add(KU.getText());
}
for (int i=0; i<totalQtyList.size(); i++) {
String qty = totalQtyList.get(i);
System.out.println(qty);
WebElement totalQty = ldriver.findElement(By.xpath("//td[@aria-describedby='jqTable_KU_Total Qty']/a[text()="+ qty + "]"));
totalQty.click();
WebElement backButton = ldriver.findElement(By.xpath("//li/a[@id='lnkBack']"));
backButton.click();
}
}
Below is the No such element error that I'm getting when I want to click the anchor tag located in next row after navigating
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//td[@aria-describedby='jqTable_KU_Total Qty']/a[text()=551]"}