2012-01-19 9 views
0

私はこのサイトのコード(http://darrellgrainger.blogspot.com/2011/02/using-selenium-20-with-webdriver-and.html)を使用してSeleniumを実行していますSafariの5のテストコードは次のようになります:Seleniumを使用してSafariをテストすると、GridExceptionが発生する

Selenium sel = new DefaultSelenium("localhost", 4444, "*safari", baseURL); 
CommandExecutor executor = new SeleneseCommandExecutor(sel); 
DesiredCapabilities dc = new DesiredCapabilities(); 
WebDriver browser = new RemoteWebDriver(executor, dc); 

browser.get("http://www.google.com"); 
WebElement input = browser.findElement(By.name("q")); 
input.sendKeys("Selenium"); 

だから私は、ローカルホストマシン上のSeleniumサーバーのスタンドアロンバージョンを起動し、私はセレンのハブに(また、ローカルホスト上の)テストノードを登録します。その後、私はテストを開始します。 org.openqa.selenium.WebDriverException:Seleniumセッションを開始できませんでした:org%2Eopenqa%2Egrid%2Ecommon%2Eexception%2EGridException%3A + Error + forwarding + new + session + The + server + returned + an + error +%3A +

どのようなエラーが発生するのですか。コンソールにはサーバー出力はありません。誰にもアイデアはありますか?私はSeleniumの最新バージョン(2.17.0)を使用しました。

EDIT:私はサファリの代わりに "firefox"を試したところ、同じ例外が出力されました。実際にはサファリのせいではありません。おそらく、グリッドからSelenium 1コードを実行する際に何か問題がありますか?

答えて

0

はこれを試してみてください。

DesiredCapabilities capabilities = new DesiredCapabilities(); 
capabilities.setBrowserName("safari"); 
capabilities.setJavascriptEnabled(true); 
CommandExecutor executor = new SeleneseCommandExecutor(new URL("http://localhost:5555/"), new URL("http://www.google.com/"), capabilities); 
WebDriver driver = new RemoteWebDriver(executor, capabilities); 
driver.get("http://google.com"); 

DefaultSeleniumオブジェクトを作成しないでください。上記のコードはSafariブラウザでうまく動作します。

+0

これは私に次の例外を与えます:org.openqa.selenium.WebDriverException:セレンセッションを開始できませんでした:org%2Eopenqa%2Egrid%2Ecommon%2Eexception%2EGridException%3A + Error + forwarding + + new + session + can not + +%3A +%7BbrowserName%3D%2Asafari%7D どのようにテストマシンをハブに登録しますか? "-browser browserName = safari"を使用しました – tester

+0

Gridノードを作成するときにブラウザ名を指定しないでください。 –

関連する問題