Reputation: 418
We have an application based on RichFaces 3.3.3 . We have created automated tests with Selenium IDE that run fine. Since the RichFaces comboboxes are not real html comboboxes but an input field with a bunch of javascript, in Selenium we need to select a value with the following trick:
type field_id "field value"
typeKeys field_id "field value"
fireEvent field_id "blur"
In order to integrate the tests into our continuous integration system, we have transformed the test to jUnit tests that use WebDriver (Selenium 2.5.0) as the backend. Unfortunately the combobox trick stopped working.
All type and typeKeys commands are translated as shown below:
// ERROR: Caught exception [ERROR: Unsupported command [fireEvent]]
driver.findElement(By.id("patientCreateDataForm:patientBirthDateInputDate")).clear();
driver.findElement(By.id("patientCreateDataForm:patientBirthDateInputDate")).sendKeys("16.06.1910");
Does anyone have any working solution to test RichFaces combobox elements?
Thanks in advance!
Upvotes: 0
Views: 2205
Reputation: 1738
The solution is as follows:
thereafter use Actions method in jUnit test. In the following example, button parameter is a combobox button id, element parameter is selected items xpath:
private void comboboxSolution(String element, String button) {
WebElement btn = driver.findElement(By.id(button));
btn.click();
WebElement myElement = driver.findElement(By.xpath(element));
Actions builder = new Actions(driver);
builder.moveToElement(myElement).click().perform();
}
Upvotes: 1
Reputation: 15250
Try something like this:
typeKeys field_id "field value"
waitForVisible (look with firebug at the id of the div that becomes visible after typing)
click (look with firebug at the id of the entry you want to select)
waitForNotVisible the_id_of_the previous_div
I have this solution working for a rich:suggestionbox component, it should be easily adaptable for a combobox.
Upvotes: 0