2013-02-13 9 views
6

私はHtmlUnitを初めて使用しており、ログインに問題があります。 以下のコードはFireFoxDriverで完璧に動作しますが、HtmlUnitDriverで失敗します。問題は「ログイン」リンクをクリックしている間にjavascriptを実行していないことです。 HTML表示用HtmlUnitドライバがJavaScriptを実行しません

サイトURL:https://fleetworks.trimbletl.com/fleet/start.do

HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.CHROME_16); 
driver.setJavascriptEnabled(true); 
WebDriverWait wait = new WebDriverWait(driver, 10); 

driver.get(fleetWorkURL); 

WebElement usernameElement = driver.findElement(By.name("j_username")); 
usernameElement.sendKeys(username); 

WebElement passwordElement = driver.findElement(By.name("j_password")); 
passwordElement.sendKeys(password); 

WebElement loginButtonElement = driver.findElement(By.linkText("Log in")); 
loginButtonElement.click(); 

wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("headerFrame")); 

のStackTrace:

13, 2013 2:47:54 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 
    WARNING: Obsolete content type encountered: 'text/javascript'. 
    13, 2013 2:47:54 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 
    WARNING: Obsolete content type encountered: 'text/javascript'. 
    13, 2013 2:47:55 PM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify 
    WARNING: Obsolete content type encountered: 'text/javascript'. 
    2013 2:47:56 PM com.gargoylesoftware.htmlunit.WebClient loadDownloadedResponses 
    INFO: No usage of download: [email protected] 

    Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 10 seconds waiting for frame to be available: headerFrame 
    Build info: version: '2.29.1', revision: 'dfb1306b85be4934d23c123122e06e602a15e446', time: '2013-01-22 12:58:05' 
    System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_11' 
    Driver info: driver.version: unknown 
at org.openqa.selenium.support.ui.FluentWait.timeoutException(FluentWait.java:255) 
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:224) 
at com.yukon.qasetup.xmlService.XMLService.main(XMLService.java:77) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:601) 
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 
+0

このメッセージはログに記録され、何かを指し示すことができます...警告:廃止されたコンテンツタイプが見つかりました: 'text/javascript'。わからない。 –

+0

私は警告が無視できると思う。 HtmlUnitはコンテンツタイプが気に入らなくても対処しているようです。本当の問題はフレーム_headerFrame_を見つけることができない例外です。 –

+1

@ user1991529:ログインボタンで発生するはずのjavascriptの特定の問題ですか?それとも、サイト上の任意のjavascriptで失敗しますか? –

答えて

-1

あなたのクラスHtmlUnitDriverは、標準セレンパッケージの一部ではないことがありますか?私が知る限り、HtmlUnitでは、DesiredCapabilities.HtmlUnit()またはDesiredCapabilities.HtmlUnitWithJavaScript()を使用してRemoteWebDriverインスタンスを作成する必要があります。

あなたはHtmlUnitDriverクラスの内部をルックアップできますか? DesiredCapabilities.HtmlUnitWithJavaScript()の代わりにDesiredCapabilities.HtmlUnit()が使用されている可能性があります。

関連する問題