how to avoid stale element exception
List<WebElement> listof items= testDriver.findElements(By.cssSelector(“css_path”))
;first-line: 1; ]for (WebElement specific_text: listof items)
am arriving @ Stale element exception when:
the specific_text is found & required action is performed
further when the for loop tries to complete the search till
the last count of "listof items"
I am not sure what exactly you are trying to do.
This exception occur when we try to do some action on element which is refreshed and as a result driver can’t recognise that element anymore.
I would suggest to capture the element again during runtime.
I faced this exception when I was working on DatePicker.
Yes agreed, I tried putting a wait time of around 2 mins, but dint help out,
In my case here, after a specific text is found & action is performed that specific item is removed from the current page & the count of “listof items” is -1.
could you please suggest on this.