Reputation: 1713
I am running a test using Selenium WebDriver
I have an issue with an input textfield ("Select Source: By Name:"). When I enter a String "ABC Premium News (Australia)" in the textfield, an option would show up. Then I need to click (or select) it. I tried ALL methods w/ fireEvent...no use.
The following is the source code:
driver.get("http://www...");
driver.switchTo().frame("mainFrame");
WebElement sourceTitle = driver.findElement(By.name("sourceTitle"));
sourceTitle.sendKeys("ABC Premium News (Australia)");
//Now a "combobox-like" option "ABC Premium News (Australia)" shows up...how do I click it?
// I tried fireEvent...it did not help. The following is one of my trials that does not work:
DefaultSelenium sel = new WebDriverBackedSelenium(driver,"http://www....");
sel.type("//input[@id='destination']", "ABC Premium News (Australia)");
sel.fireEvent("//input[@id='destination']", "keydown");
// In addition to keydown, I tried: onclick, onfocus, onblur...
Upvotes: 1
Views: 4098
Reputation: 2847
I know this is not the best one could come up with but still it can be used as temporary workaround.
WebElement sourceTitle = driver.findElement(By.name("sourceTitle"));
WebElement small = driver.findElement(By.cssSelector("li#nameExampleSection label + small"));
sourceTitle.sendKeys("ABC Premium News (Australia)");
Thread.sleep(5000);
Actions actions = new Actions(driver);
actions.click(small).perform();
Upvotes: 2