Selenium testing RichFaces comboBox controls

Ok, so I’ve spent the last day and a half chasing down a really weird bug I was seeing with our Selenium integration tests.

Basically, we had a RichFaces rich:comboBox component – which gives you a thing that looks like a drop down combo box, but also allows you to type free-form text into it. It does fancy things like auto-completion, etc.

What I had was an ajaxValidator that would trigger when the “onblur” event was fired at the component. This was working fine when I’d try it manually, i.e. I could type something into the field, hit tab (or click away from the field or whatever), and the validation would update, showing that the field now had a value (instead of complaining about not having one).

However, when I tested it using Selenium, using selenium.type() I could see the input appear in the text box, but the validation message would never go away.

Something with the event system in the combo box is way messed up, and you should test it using something like:

selenium.typeKeys( your_elementcomboboxField, "Some text" );
selenium.fireEvent( your_elementcomboboxField, "blur" );

This simulates a user actually typing each letter in, like a human would do, rather than just setting the field value. You then fire the onblur event, so simulate the user leaving the field.

3 comments

    • Gunnar on September 29, 2009 at 12:16 am
    • Reply

    I faced the same problem today. However the above solution did not work for me. I guess the reason is a different richFaces version (3.3.1 in my case). However I could beat the comboBox the following way:

    selenium.type(myRichComboField, versichererTiere);
    selenium.fireEvent(myRichComboField, “keyup”);

    • empi on October 30, 2009 at 1:30 am
    • Reply

    This worked for me:

    String inputField = caption + comboboxField;
    selenium.windowFocus();
    selenium.focus(inputField);
    selenium.type(inputField, text);
    selenium.fireEvent(inputField, keyup);
    selenium.keyPressNative(\+KeyEvent.VK_ENTER);

    we also figured out how to check the content of an ajax-reRendered comboBox.
    Let me know if you need it: empinator a gmail com

    • Elangovan on December 28, 2011 at 4:56 pm
    • Reply

    Hi guys,

    It works for me too…….

    selenium.type(myRichComboField, versichererTiere);
    selenium.fireEvent(myRichComboField, “keyup”);

    Thank you..

Leave a Reply

Your email address will not be published.