2017-02-09 13 views
1

私の質問または問題=セレンリモートサーバーでブラウザを実行できません。どうすればこの問題を解決できますか?(Chrome、Firefox、PhantomJS)ブラウザをSeleniumサーバーでスタンドアロンで実行するにはどうすればよいですか?

私の環境:

  • オペレーティングシステムWindows 10
  • 私は日食を使用しています(バージョン:ネオンリリース(4.6.0))は、Java 1.8
  • セレンのWebドライバ3.0.0
  • セレンサーバスタンドアロン-3.0.1.jar

私は中セレンサーバースタンドアロンで起動しますcmd。 (ファイルはユーティリティに保存されている「セレンサーバスタンドアロン-3.0.1.jarは、」私のCドライブ上のフォルダ)

C:\Windows\system32> cd\ 
C:\> cd utilities 
C:\Utilities> java -jar selenium-server-standalone-3.0.1.jar 

enter image description here

その後セレンサーバースタンドアロン起動し、すべてのルックス細かい

enter image description here

私は私のテストを実行

Eclipseはこのエラーを提供しています。cmdで

Feb 09, 2017 10:36:35 AM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end 
Feb 09, 2017 10:36:35 AM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Falling back to original OSS JSON Wire Protocol. 
Feb 09, 2017 10:36:36 AM org.openqa.selenium.remote.ProtocolHandshake createSession 
INFO: Falling back to straight W3C remote end connection 
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, version=, platform=ANY}], required capabilities = Capabilities [{}] 
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700' 
System info: host: 'MWLTSHAUNCR', ip: '192.168.56.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45' 
Driver info: driver.version: RemoteWebDriver 

私はこのエラーを受け取っ: enter image description here

私のコードは、私が追加したremoteDriver部分について、このようになります。私は「セレン・サーバースタンドアロン・3.0.1.jar」ファイルを保存したフォルダに、すべてのドライバをコピーしたクラスとコンストラクタ

public class browser { 
    private browser (WebDriver driver){ 
     browser.driver = driver; 
    } 

    public static void runRemoteDriver(){ 
     try { 
      WebDriver webDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.firefox()); 
      new browser (webDriver); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 

答えて

2

が含まれています。その後、それは働いた!

enter image description here

私はcmdのコマンドを使用してサーバーを開始しました:

java -jar selenium-server-standalone-3.0.1.jar 

その後、あなたの中にあなたが例えば実行したいブラウザを指定しなければなりませんコード:

WebDriver webDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.firefox()); 
    WebDriver webDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.chrome()); 
    WebDriver webDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.phantomjs()); 
2

私はあなたがいると思いますdriver.exeファイルのパスがありません。 2つのオプションがあります。

1.一般的な方法でSystem.setProperty()を使用することができます。

2.以下のように、パスを使用してRemoteDriverを起動できます。

java -Dphantomjs.binary.path=phantomjs.exe -jar selenium-server-standalone-3.4.0.jar 

このコード行は、接続を確立する責任があります。

WebDriver webDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.firefox()); 
関連する問題