RE: how to avoid stale element exception

List<WebElement> listof items= testDriver.findElements(By.cssSelector(“css_path”))

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"
shubha Default Asked on November 25, 2014 in Selenium WebDriver.

Hi Shubha

Do you mind posting your code here ?

on November 26, 2014.
Add Comment
3 Answers

Hi,

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.

Train Answered on November 26, 2014.

Ranjodh is right.

on November 26, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.