We are using Selenium WebDriver and JBehave to run "integration" tests on our web-app. I have a method that will enter a value into a form input.
@When("I enter $elementId value $value")
public void enterElementText(final String elementId, final String value) {
final WebElement webElement = webdriver.findElement(By.id(elementId));
webElement.clear();
webElement.sendKeys(value);
}
But when I try to use this to select an item in a drop-down list it (unsurprisingly) fails
java.lang.UnsupportedOperationException: You may only set the value of elements that are input elements
How do I select a value in the combo?
The Selenium paradigm is that you are supposed to simulate what a user would do in real life. So that would be either a click or a keys for navigation.
As long as you get a working selector to feed into findElement you should have no problem with it. I have found CSS selectors to be a better bet for things involving multiple elements. Do you have a sample page?
By using ext js combobox typeAhead to make the values visible in UI.
If that doesn´t work this is also worth a try
The Support package in Selenium contains all you need:
You can import it through NuGet as a separate package: http://nuget.org/packages/Selenium.Support
This is how to do it: