2013-05-06 69 views
0

我們正在使用Selenium WebDriver測試應用程序。 HTMLUnitDriver是我們的選擇(因爲非gui測試),有時用於PresentationProposes的IEDriver。無論如何,我嘗試點擊一個按鈕,這個必須打開一個豐富的:popuPanel(模態=真),然後單擊該面板上的鏈接。使用IEDriver並沒有問題,但使用HTMLUnitDriver時,popupPanel無法打開。我試圖以多種方式執行這些點擊:WebDriver開放豐富:popupPanel

JavascriptExecutor jsdriver = (JavascriptExecutor) driver; 
    jsdriver.executeScript("$('input[id$=freigabeCmd_id]').focus();"); 
    //below are the other tries 
    // jsdriver.executeScript("$('input[id$=freigabeCmd_id]').click();"); 
    // jsdriver.executeScript("window.document.getElementById('editorViewForm_id:freigabeCmd_id').click()"); 
    // jsdriver.executeScript("arguments[0].click()", freigabeButton); 
    // jsdriver.executeScript("arguments[0].fireEvent('onclick');", freigabeButton); 

進一步我嘗試了「正常方式」:

 freigabeButton.click(); 
    //below are other ways i found here on stackoverflow 
    // freigabeButton.sendKeys(Keys.ENTER); 
    // new Actions(driver).moveToElement(freigabeButton).clickAndHold().release().build().perform(); 

,但沒有給我帶來獲取popupPanel「可見」。任何人都知道爲什麼?!我現在真的被卡住了。如果你需要更多的信息,請讓我知道。

使用:版本的HtmlUnit 2.12和最新SeleniumVersion

回答

0

這可能是你的web應用使用JavaScript來推出豐富的彈出面板,並且您禁用了javascript運行HtmlUnitDriver?它是disabled by default,所以你需要明確地啓用它。

+0

Javascript已啓用。 client.getOptions()setJavaScriptEnabled(真)。 – goya 2013-05-07 16:36:14