Hi,
I have 2 similar pages with a filter and a table with the element I am looking for.
The goal is to enter the name in the filter and refresh the page until the table has the element I am looking for.
On the first page my code works flawlessly, however on the second page I keep getting a stale element after the first run of my while-loop, and I can’t figure out why.
Here is to hoping someone can find an issue in my code, the stale element is thrown when the ‘rows’-list is created.
WebElement tBody = null
String element = null
int x = 0
int sleepCounter = 0
loop:
while(element == null) {
// WebElement tBody = null
TestObject to = 'Class to find the filter-input'
wait.andDLClick(to, 10)
while(tBody == null) {
tBody = driver.findElement(By.tagName('tbody'))
}
List <WebElement> rows = tBody.findElements(By.tagName('tr')) // stale element get thrown here every time after the first run
try {
*validation of the element using the 'rows' list created above
or if the element is not found I have a counter in place to either:
* refresh the page and try again from with the while loop
* or fail the test when a threshold is reached
} catch (e) {
//e.printStackTrace()
}
}// end while loop