Selenium - Input Text - Inconsistent failures

3,516 views
Skip to first unread message

hoan

unread,
Feb 11, 2013, 8:00:36 PM2/11/13
to robotframe...@googlegroups.com
Hi all,

I have been having intermittent problems with the Selenium keyword Input Text. I am hoping for some pointers on how I can track this down.

The problem is that the Input_Text keyword would SOMETIME not enter the text into the textbox. A test would run fine in 1 build and fail in the next build because the textbox did not contain the input text. Once my test case encountered this problem, none of the Input_Text keywords would enter the text as expected. Other form interactions such as Click_Element or Select_From_List would still work.

Background:
CentOS 6
Firefox 10
Python 2.6 (Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23))
Selenium 2.25.0 (selenium-2.25.0-py2.6.egg-info)
Robotframework 2.7.6 (robotframework-2.7.6-py2.6.egg-info) and (robotframework_selenium2library-1.0.1-py2.6.egg-info)

Testing a Web application with AJAX and jQuery rendering.

I have tried checking the text on the element after the Input_Text keyword, and retry the Input_Text keyword if needed.
I even tried Reload_Page before retrying the Input_Text keyword.
I have made sure the element is visible before the Input_Text keyword.
I have Capture_Page_Screenshot and can see that the element is visible.
I log the "style" attribute of the element and all of its direct ancestors to make sure they don't have "display: none" value.
None of these helped or gave any clues.

Below is my custom keyword. When the problem occurs, ${entered_text} would always be blank, and the test case would time out from the keyword Wait_Until_Keyword_Succeeds on UI_Input_Text_And_Verify. I attached here a snippet of my debug log.



UI_Input_Text    [Arguments]                  ${locator}                  ${text}                                                                                     
    Wait_Until_Page_Contains_Element    ${locator}                                                                                                              
    Wait_Until_Keyword_Succeeds           ${VISIBILITY_TIMEOUT}       ${VISIBILITY_RETRY}                                                                         
    ...                                                     UI_Input_Text_And_Verify      ${locator}             ${text}                                                              
                                                                                                                                                                
UI_Input_Text_And_Verify  [Arguments]   ${locator}                               ${text}                                                                                     
    Wait_Until_Keyword_Succeeds            ${VISIBILITY_TIMEOUT}       ${VISIBILITY_RETRY}                                                                         
    ...                                                      Element_Should_Be_Visible   ${locator}                                                                                  
    Input_Text                                          ${locator}                              ${text}                                                                                     
    ${entered_text}=                                  Get_Value                            ${locator}                                                                                  
    Should_Be_Equal                                ${text}                                  ${entered_text}                                                                             

Kevin O.

unread,
Feb 12, 2013, 9:29:55 AM2/12/13
to robotframe...@googlegroups.com
I have experience a very similar issue with Input Text clearing the existing text, but not typing the new text, although under Se 2.21.3 & IE 7/8.
If you look at the debug level log events its clearly a Selenium issue and not a Selenium2Library issue.
I also verified by writing a WebDriver test directly in Python and encountered the same behavior.
My experience was that in a certain area of the application, Input Text would never work correctly, however. It was not intermittent.
On the pages where Input Text did not work correctly, Click Button and Click Element also did not work on buttons.
After digging through the AUT's JavaScript, asking in the Se Google group, and scratching my head, I gave up.
In the area of the AUT that does not seem to get along with Selenium, I use JavaScript to set the text, followed by the Simulate keyword to fire DOM events if necessary.
For the buttons I also use Simulate instead of Click *.
It bothered me to do it that way, but it wasn't long ago where Selenium RC was the big thing and it did a lot more "cheating" similar to this.

There is also another part of the same web app that has an intermittent problem similar to this - text is partially entered and wiped out. This happens when an AJAX response causes the JS to replace the element as you are trying to enter text. This is reproducible manually and due to sloppy programming.
Have you watched the test execute to verify that no text is entered at all?

Kevin

Kevin O.

unread,
Feb 12, 2013, 9:32:03 AM2/12/13
to robotframe...@googlegroups.com
Forgot to say that I too saw the behavior where once Input Text failed to input text, you could navigate back to a page where it previously worked and it would not work on the same element it did originally (just clears it).

elizaleong

unread,
Feb 12, 2013, 7:36:19 PM2/12/13
to robotframe...@googlegroups.com
I also experienced that intermittent problem with Input Text. It seems to be limited to Firefox, and like you said, once it happens, it always fails at random spots. This happens when I run it manually to watch what's going on.  It would enter the text, and then clear it form random text boxes in the form.  When I run my tests from Jenkins (which runs without a display), it works fine.  Thanks for the workaround suggestions.

hoan

unread,
Feb 13, 2013, 9:42:15 PM2/13/13
to robotframe...@googlegroups.com
I did not realize there was a "Simulate" keyword. Your workaround works great, although I would also like to find out what caused the problem. Hope to get some time to look into it a little more.

Xinbo Jiang

unread,
Nov 21, 2014, 6:34:29 AM11/21/14
to robotframe...@googlegroups.com, hoan...@openx.com
probably too late for this. but I encountered the problem, and seems to have fixed it by slowing down the selenium speed: Set Selenium Speed 1

yle me

unread,
Feb 20, 2017, 7:04:37 AM2/20/17
to robotframework-users, hoan...@openx.com
 
I had a similar issue, in my case I was using an xpath that I thought was specific, but it wasn't.
I am relatively new to RobotFramework so I did a schoolboy mistake.
My error was that I didn't understand how the DOM works, so if you use firepath to find xpaths, when you select an element and it's highlighted, you might want to look down on the left, it will say "1 matching node".
My one found 3 matching node and robot framework could select the text field, but couldn't use it. I had to write a more specific xpath myself.
It works fine now.
I also found very useful reading about the extended selenium 2 library. You can Google it, it's all about AJAX and how it interferes with web elements.

I hope this helps. 
Reply all
Reply to author
Forward
0 new messages