3

私は Selenium を初めて使用し、http://docs.seleniumhq.org/docs/03_webdriver.jspの例を使用しようとしています。しかし、うまくいきません。Mavenを介したJUnitテストから、またはJavaアプリケーションとしてのEclipse Junoから実行するたびに、次のような結果が得られます。

Exception in thread "main" org.openqa.selenium.WebDriverException: Session not found: 1d1a9aa2-f089-4f36-bb05-e1505c7b4e85
Command duration or timeout: 28 milliseconds
Build info: version: '2.33.0', revision: '4ecaf82108b2a6cc6f006aae81961236eba93358', time: '2013-05-22 12:00:17'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0'
Session ID: 1d1a9aa2-f089-4f36-bb05-e1505c7b4e85
Capabilities [{handlesAlerts=true, rotatable=false, databaseEnabled=true, locationContextEnabled=true, acceptSslCerts=true, applicationCacheEnabled=true, cssSelectorsEnabled=true, nativeEvents=true, takesScreenshot=true, platform=XP, browserName=firefox, javascriptEnabled=true, version=17.0.6, webStorageEnabled=true, browserConnectionEnabled=true}]
Driver info: org.openqa.selenium.firefox.FirefoxDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...

失敗しているコードは次のとおりです。

public static void main(String[] args) {
    // Create a new instance of the Firefox driver
    // Notice that the remainder of the code relies on the interface, 
    // not the implementation.
    WebDriver driver = new FirefoxDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com"); // FAILURE

私はそれをデバッグし、FirefoxDriver コンストラクターが呼び出されると、Firefox ウィンドウが実際に私のシステムで開き、その後消えてから再び開くことを確認しました。次に、driver.get() 呼び出しで失敗します。

このサイトを検索したところ、問題への参照が見つかりました。問題は Chrome または IE にありましたが、Firefox は機能しました。他のすべては別のエラーのようでした。開いたままのウィンドウから Firefox のバージョンを取得しようとしましたが、[Firefox について] を選択したときに表示されるのは次のとおりです。

<window xmlns:html="http://www.w3.org/1999/xhtml"
^

Firefox を直接起動すると、Firefox のバージョンが 17.0.6 で、「現在、esr 更新チャネルを使用しています」と表示されます。ちなみに、そのウィンドウを開いたままにしても効果はありません。新しい Firefox ウィンドウが開き、閉じ、再度開いて、そのままにしておきます。

4

1 に答える 1

0

私はあなたとまったく同じ設定をしています(Windows / Selenium 2.33 / FF 17.0.6)、まったく同じ動作を見ていました。ネットで調べられることはすべて試しました。

次に、この同じ問題が発生しているユーザーが会社の FF 17.0.6 ESR の配布を使用しており、(会社の FF インストールと一緒に) FF 17.0.6 ESR の新しいコピーをダウンロードしてインストールしたときに (そして FF を指摘した) ことをどこかで読みました新しい Firefox.exe バイナリを使用するドライバー) は機能しました。

私はFFの会社展開バージョンを使用していたので、それが私が試したもので、うまくいきました!! これは、FF 17.0.6 ESR の 2 番目のインストールを使用した私のコードです。

File pathToBinary = new File("C:\\Program Files (x86)\\Mozilla Firefox\\Firefox.exe");
FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);
FirefoxProfile ffProfile = new FirefoxProfile();
WebDriver ffDriver = new FirefoxDriver(ffBinary, ffProfile);
System.out.println("***Execute testGetTitle()");
ffDriver.get(pdURL);

(new WebDriverWait(ffDriver, 10)).until(new ExpectedCondition<Boolean>() {
     public Boolean apply(WebDriver d) {
     return d.getTitle().equals("Your Title Here")
     }
});

ffDriver.quit();

それを試してみて、それが FF のインストールに問題があるかどうかを確認してください。

于 2013-06-26T17:28:54.740 に答える