我正在運行使用硒的webdriver如何點擊自動提示輸入文本框中的選項? webdriver的
測試硒我有一個問題與輸入文本框(「選擇來源:名稱:」)。 當我在文本框中輸入字符串「ABC Premium News(澳大利亞)」時,會顯示一個選項。然後我需要點擊(或選擇)它。我嘗試了所有方法w/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...
看看這裏http://stackoverflow.com/questions/9202061/test-autocomplete-with-selenium-webdriver – 2013-03-17 05:33:44
對不起@Amine Hajyoussef。我再次嘗試,似乎這種方法只幫助將值輸入到文本文件中,但是,它不會幫助選擇「類似組合框」選項。 ANYBODY,請運行上面的代碼行或訪問網站查看文本框。 – CHEBURASHKA 2013-03-17 06:15:58
你能告訴我們html和截圖嗎? – 2013-03-18 07:34:45