Skip to content

'Select From List' unreliable #106

Closed

Description

@know1nos

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?

Activity

  1. j1z0 commented on Sep 11, 2012

    @j1z0
    Contributor

    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 notifications@github.com 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.

  2. emanlove commented on Sep 11, 2012

    @emanlove
    Member

    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 notifications@github.com 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
    #106 (comment).

  3. know1nos commented on Sep 11, 2012

    @know1nos
    Author

    the implicit wait fixed everything, thank you all

  4. know1nos commented on Sep 12, 2012

    @know1nos
    Author

    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?

  5. ombre42 commented on Sep 12, 2012

    @ombre42
    Contributor

    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.

  6. j1z0 commented on Sep 12, 2012

    @j1z0
    Contributor

    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 notifications@github.com 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.

  7. emanlove commented on Oct 1, 2012

    @emanlove
    Member

    @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.

  8. ombre42 commented on Oct 2, 2012

    @ombre42
    Contributor

    Sorry, I have not tried it out.

  9. emanlove commented on Oct 2, 2012

    @emanlove
    Member

    @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.

  10. know1nos commented on Oct 10, 2012

    @know1nos
    Author

    @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.

  11. emanlove commented on Dec 11, 2012

    @emanlove
    Member

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

  12. juacompe commented on Sep 27, 2014

    @juacompe

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions