Stale element reference exception

61 views
Skip to first unread message

satya sree

unread,
Nov 22, 2015, 12:18:04 PM11/22/15
to Selenium Users
Im getting stale element reference exception during the below situation

I have three continuos dropdown fields. 1st dropdown is independent
2nd is dependent on first dropdown
3rd is dependemt on 2nd dropdown
--on selection of 1st dropdown the page gets refreshed then we need to select value from second dropdown and so on fr 3rd also.
When i tried writing using select like a normal dropdown selection
1st dropsown is selected and then 2nd dropdown value is being selected before refresh of the page occurs after frst droodown. Plz lettme knw fr any solution

rajee sudh

unread,
Nov 22, 2015, 1:14:56 PM11/22/15
to seleniu...@googlegroups.com
you can use Selenide, it solves the major stale element exception issue in selenium


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/5c48e08e-c69e-4ee7-a23f-927a3b516770%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

satya sree

unread,
Nov 22, 2015, 1:17:39 PM11/22/15
to seleniu...@googlegroups.com

What is selenide? Can you plz explain it with an example

You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/SLKj0xx18uY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

rajee sudh

unread,
Nov 22, 2015, 1:48:24 PM11/22/15
to seleniu...@googlegroups.com
http://selenide.org/quick-start.html  - using the selenide API should help you with stale exceptions

Shawn McCarthy

unread,
Nov 22, 2015, 5:51:13 PM11/22/15
to Selenium Users
Hi,

I suggest you learn why you are getting the StaleElementException, before you try and use a third party tool to help with it. It will give you a better understanding, and could help you in the future.

You get a StaleElementException when you locate an element, the element changes, than you try to interact with the element. I suggest you:
1) Select from the first drop down
2) Have an explicit wait for the second drop down to be populated
3) Find the element for the second drop down
4) Select from the second drop down
5) Have an explicit wait for the third drop down to be populated
6) Find the element for the third drop down
7) Select from the third drop down

I don't disagree with using Selenide, I just think it would be very useful to know why you are getting the StaleElementExceptions in the first place.

MWQA

unread,
Nov 23, 2015, 5:43:17 AM11/23/15
to Selenium Users
I find the easiest way is to put a wrapper around FindElement, i.e.

        public IWebElement find(By locator)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));
            wait.Until(ExpectedConditions.ElementIsVisible(locator));
            return driver.FindElement(locator);
Reply all
Reply to author
Forward
0 new messages