【发布时间】:2013-03-19 06:50:24
【问题描述】:
我正在使用 Selenium WebDriver 运行测试
我的输入文本字段有问题 ("Select Source: By Name:")。 当我在文本字段中输入字符串“ABC 高级新闻(澳大利亚)”时,会出现一个选项。然后我需要单击(或选择)它。我尝试了所有带有 fireEvent 的方法...没有用。
以下是源码:
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...
【问题讨论】:
-
我很抱歉@Amine Hajyoussef。我又试了一次,似乎这种方法只有助于将值输入到文本文件中,但是,它没有帮助选择“组合框 - 类似”选项。任何人,请运行上述代码行或访问网站查看文本字段。
-
你能给我们看看html和截图吗?