StaleElementReferenceException in ExpectedConditions -->elementToBeClickable

310 views
Skip to first unread message

kapil aggarwal

unread,
Jan 3, 2014, 6:27:44 AM1/3/14
to webd...@googlegroups.com
Hi All 

Just wondering ,if  there is scope of StaleElementReferenceException in WebDriver ExpectedConditions-->elementToBeClickable
Checking the source code of the function ,StaleElementReferenceException is  in catch and returns null. 
But there is  line of code in method ExpectedConditions.elementToBeClickable. which is throwing this exception at random time(currently not having any concrete test to display)

public ExpectedCondition<WebElement> visibilityOfElement =
          ExpectedConditions.visibilityOf(element);

and if we check above code there is no catching of StaleElementException

Can some please help in understanding if there is possibility of staleElementException in the above mentioned method? if yes - is this known issue? Any work around to prevent random failures?


Thanks
Kapil Aggarwal
StackTrace.txt

kapil aggarwal

unread,
Jan 6, 2014, 5:27:04 AM1/6/14
to webd...@googlegroups.com
Hi All 

Please help in below,let me know if i need to rephrase the question or it sounds confusing. 

Thanks
Kapil Aggarwal

SuperKevy

unread,
Jan 6, 2014, 9:27:11 AM1/6/14
to webd...@googlegroups.com
Stale Element. why not fetch the element again? 

Mattayi

unread,
Jan 6, 2014, 8:18:15 PM1/6/14
to webd...@googlegroups.com
Try this code

WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(elementToBeClickable(element));

kapil aggarwal

unread,
Jan 7, 2014, 2:03:15 AM1/7/14
to webd...@googlegroups.com
Hi Mattayi

Please read the question i am using the same function and it is throwing staleElementReferenceException 
I am using proxy WebElement from PageObjectFactory

Ken P

unread,
Jan 24, 2014, 4:12:31 PM1/24/14
to webd...@googlegroups.com
This part stands out:

"Any work around to prevent random failures?"

"Random" typically (in my experience) indicates a race condition in your test suite.  Solve that and your stale element will go probably away.

kapil aggarwal

unread,
Jan 25, 2014, 2:30:09 AM1/25/14
to webd...@googlegroups.com
Hi All 

Thanks for contributing ,I think i have figured some of the problem associate with it 

First of all I am using pageObject and proxy elements in the ExpectedConditions which i think should not be used
Secondly there is a toString in method in FLuentWait.wait method which throws this exception 

Try to explain with example
When we pass proxy elements to ExpectedCondition.elementTobeClickable there would be 2 scenarios on high level
1>Element is found and clickable-Condition true
2>Element not found or not clickable-Condition false-->TimeoutException 

1st scenario works well but in seconds scenario in timeOutException there toString() method to display proper error and when toString method is called on the proxyElement which is not found then again it tries to locate the element and NoSuchElement or staleElementException is thrown .

Conclusion is --
ExpectedCondition class doesnot work with proxy WebElements if at all it needs to be used then make Custom method with toString override so Exception in FluentWait.until method should not be thrown

Thanks


--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/363rqTIawDE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.
To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages