SeleniumLibrary icon indicating copy to clipboard operation
SeleniumLibrary copied to clipboard

'Select From List' unreliable

Open know1nos opened this issue 14 years ago • 12 comments

Over the past couple weeks I've been encountering several issues with the 'Select From List' keyword.

The latest issue with this keyword has been that it fails AFTER the keyword succeeds in selecting the value from the list element. It returns: "StaleElementReferenceException: Message: u'Element is no longer attached to the DOM' "

Adding 'Wait Until Page Contains Element" before the keyword always passes. Adding 'Wait Until Page Contains Element" also passes after running 'Run Keyword and Continue On Failure' on the 'Select From List' keyword.

I have also executed all of the same test cases ~200 times on several different websites with the original SeleniumLibrary without being able to replicate any of the issues, so I do not believe this is a problem with with the operation of the webpages I am running the tests on.

Any ideas?

know1nos avatar Sep 10 '12 15:09 know1nos

I have seen this error in other situations and it usually means that the DOM has changed. So in the case you described is it true that selecting an element from the list triggers some JavaScript call that changes the list or loads a new page or something like that?

What I've done as a solution to this problem in a framework I built that wraps s2l is catch the error an I'd it occurs re-execute the command. In my situation this is necessary because selecting an item from the drop down is changing the DOM.

Do you think such a solution will work in your case or do you have something else going on.

Cheers, Jeremy

On Sep 10, 2012, at 23:37, know1nos [email protected] wrote:

Over the past couple weeks I've been encountering several issues with the 'Select From List' keyword.

The latest issue with this keyword has been that it fails AFTER the keyword succeeds in selecting the value from the list element. It returns: "StaleElementReferenceException: Message: u'Element is no longer attached to the DOM' "

Adding 'Wait Until Page Contains Element" before the keyword always passes. Adding 'Wait Until Page Contains Element" also passes after running 'Run Keyword and Continue On Failure' on the 'Select From List' keyword.

I have also executed all of the same test cases ~200 times on several different websites with the original SeleniumLibrary without being able to replicate any of the issues, so I do not believe this is a problem with with the operation of the webpages I am running the tests on.

Any ideas?

— Reply to this email directly or view it on GitHub.

j1z0 avatar Sep 11 '12 01:09 j1z0

Another option is to use the new implicit_wait functionality within WebDriver and the Selenium2Library. Implicit_wait should handle minor discrepancies with timing and AJAX calls. Does your 'Select From List' keywords fail at the same point on every test run or are these failures sporadic? Sporadic failures can be fixed by using the implicit_wait. See

http://rtomac.github.com/robotframework-selenium2library/doc/Selenium2Library.html#importing

http://rtomac.github.com/robotframework-selenium2library/doc/Selenium2Library.html#Set%20Selenium%20Implicit%20Wait

http://seleniumhq.org/docs/04_webdriver_advanced.html#explicit-and-implicit-waits

There are trade-offs with using implicit_wait in terms of test run length and some good test designs. Implicit_wait will check initially if the operation was successful and return if it passes. But ion initial failure will continue to poll up to either it suceeds or to the implicit wait time if it fails. This is good in situations like yours where your might be waiting for a page reload that takes an indeterminate or variable amount of time (i.e. AJAX calls). But in other places where a test operation fails and you didn't specifically tell robot framework to move on if failure it could poll for the full wait time thinking it might succeed. This could be an indication that there is an unforeseen failure or an improper check. Just be aware that your test run timings may change and you should review those changes.

Ed

On 09/10/2012 09:26 PM, Jeremy Johnson wrote:

I have seen this error in other situations and it usually means that the DOM has changed. So in the case you described is it true that selecting an element from the list triggers some JavaScript call that changes the list or loads a new page or something like that?

What I've done as a solution to this problem in a framework I built that wraps s2l is catch the error an I'd it occurs re-execute the command. In my situation this is necessary because selecting an item from the drop down is changing the DOM.

Do you think such a solution will work in your case or do you have something else going on.

Cheers, Jeremy

On Sep 10, 2012, at 23:37, know1nos [email protected] wrote:

Over the past couple weeks I've been encountering several issues with the 'Select From List' keyword.

The latest issue with this keyword has been that it fails AFTER the keyword succeeds in selecting the value from the list element. It returns: "StaleElementReferenceException: Message: u'Element is no longer attached to the DOM' "

Adding 'Wait Until Page Contains Element" before the keyword always passes. Adding 'Wait Until Page Contains Element" also passes after running 'Run Keyword and Continue On Failure' on the 'Select From List' keyword.

I have also executed all of the same test cases ~200 times on several different websites with the original SeleniumLibrary without being able to replicate any of the issues, so I do not believe this is a problem with with the operation of the webpages I am running the tests on.

Any ideas?

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/rtomac/robotframework-selenium2library/issues/106#issuecomment-8444217.

emanlove avatar Sep 11 '12 13:09 emanlove

the implicit wait fixed everything, thank you all

know1nos avatar Sep 11 '12 17:09 know1nos

Has anyone else found that 'Select From List' is slightly slow in chrome and horrifically slow in IE? It appears entirely dependent on the number of items in the list. For example if there are 4 items in the list on IE it takes a few seconds which is acceptable... BUT when the list contains ~50 items it literally takes minutes.

Has anyone else encountered this issue or developed any faster work arounds?

know1nos avatar Sep 12 '12 15:09 know1nos

yes it is horrible on IE. have you seen this pull request which uses functionality built-in to Selenium for dealing with Select type elements. I haven't tried it but I think it will speed things up a lot.

ombre42 avatar Sep 12 '12 18:09 ombre42

This is a know issue. I believe there is a patch existing for it as well. I just. Red to review the patch and merge it in. I'll try to get to that today.

Cheers, Jeremy

On Sep 12, 2012, at 23:08, know1nos [email protected] wrote:

Has anyone else found that 'Select From List' is slightly slow in chrome and horrifically slow in IE? It appears entirely dependent on the number of items in the list. For example if there are 4 items in the list on IE it takes a few seconds which is acceptable... BUT when the list contains ~50 items it literally takes minutes.

Has anyone else encountered this issue or developed any faster work arounds?

— Reply to this email directly or view it on GitHub.

j1z0 avatar Sep 12 '12 23:09 j1z0

@know1nos @ombre42 Have either of you tried cherry picking out the 'Select From List' changes (see #68 - commits and tested within your situations? I'm interested in your results as I don't have any good test which do a lot of select calls, especially those made to a remote test server.

emanlove avatar Oct 01 '12 13:10 emanlove

Sorry, I have not tried it out.

ombre42 avatar Oct 02 '12 03:10 ombre42

@ombre42: I think these changes are an improvement but I think there is still room for improvement with the select functionality. What I was trying in asking whether or not you had a chance to look was to help in deciding whether or we should cut a release or wait till we have more improvements.

emanlove avatar Oct 02 '12 13:10 emanlove

@emanlove have not tried it but will try to get to it within the week, have lots of timing data to compare it to as well once I get around to it. I'll try remember to report back numbers for you if you're interested as well once I get to it. Have too many other projects on my plate right now though so I bumped up the processing power dedicated to the tests instead as a temporary fix.

know1nos avatar Oct 10 '12 18:10 know1nos

'Select' keywords were updated under Selenium2Library version 1.1 and reliability should be improved.

emanlove avatar Dec 11 '12 14:12 emanlove

I tried implicit_wait=5 but it did not do the magic in my case. I get around the problem by using keyword "Focus " to get the new element reference before selecting the option. That works for me.

juacompe avatar Sep 27 '14 04:09 juacompe