1

Selenium WebDriver を使用してテストを実行しています

入力テキストフィールド("Select Source: By Name:")に問題があります。テキストフィールドに「ABC Premium News (Australia)」という文字列を入力すると、オプションが表示されます。次に、それをクリック (または選択) する必要があります。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...
4

1 に答える 1

2

これが思いつく最善のものではないことはわかっていますが、それでも一時的な回避策として使用できます。

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();
于 2013-03-18T17:34:44.190 に答える