2

JavaでFirefoxでwebdriverを使用しています。注釈を使用して要素を検索しています。例:

@FindBy(id = "terminal")
private WebElement selectTerminal;

ページのレンダリングに失敗し、何らかの理由でこの要素がレンダリングされないとしましょう。エラーメッセージは非常にわかりにくく、Jenkinsでリモートでテストを実行している場合、デバッグして正確に何が起こったのかを確認するのは非常に困難です。

The element could not be found (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 72 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.20.0', revision: '16008', time: '2012-02-28 15:00:40'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '2.6.32-312-ec2', java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver

セレクターを含む詳細情報を取得するにはどうすればよいですか? もちろん、try / catchなどを使用して、ある種のヘルパーメソッドでラップすることもできますが、知りたいのは、セレクターが表示されない理由と、その警告を取り除くにはどうすればよいですか?

ありがとう!

4

1 に答える 1

0

これは理想的な解決策ではありませんが、同じ問題を解決するのに役立ちました.

webdriver システム プロパティを設定して、ファイルへのログ記録を有効にします。

-Dwebdriver.firefox.logfile=/tmp/ff.log 

またはテストコードで:

System.setProperty("webdriver.firefox.logfile", "/tmp/ff.log")

次に、ff.log に、エラーが発生した場所の出力が表示されます。

[6.389][FINE]:      Command received (/session/5a4c8a0a7ef5453467687267348e8cb3/element)    with params {
"using": "xpath",
"value": "//input[@class='login-submit']
}

[6.389][FINER]:     Waiting for all views to stop loading...
[6.390][FINER]:     Done waiting for all views to stop loading
[6.505][FINER]:     Waiting for all views to stop loading...
[6.506][FINER]:     Done waiting for all views to stop loading
[6.506][WARNING]:   Command finished (/session/5a4c8a0a7ef5453467687267348e8cb3/element)   with response {
   "sessionId": "5a4c8a0a7ef5453467687267348e8cb3",
    "status": 7,
    "value": {
    "message": "The element could not be found"
 }
} 

少なくとも今では、どの要素がxpathに基づいているかがわかります。これはChromeDriverでも機能します

于 2013-07-24T15:24:23.820 に答える