2017-10-30 6 views
1

私はJavaでSeleniumを学んでいます。私は以下の問題を抱えています。私はHUBでテストを開始しようとし、次のエラーが表示されます。Selenium Gridのクロムドライバを設定するには?

コード:Eclipseのコンソールで

package selenium; 

import java.io.File; 
import java.net.MalformedURLException; 
import java.net.URL; 

import java.util.concurrent.TimeUnit; 

import org.openqa.selenium.Platform; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.chrome.ChromeOptions; 

import org.openqa.selenium.remote.DesiredCapabilities; 
import org.openqa.selenium.remote.RemoteWebDriver; 

public class FromHub { 
    public static void main(String[] args) throws MalformedURLException { 

    RemoteWebDriver driver; 

    DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 
    ChromeOptions options = new ChromeOptions(); 
    options.setBinary(new File("D:\\Projektek\\Selenium\\chromedriver.exe")); 
    capabilities.setCapability(ChromeOptions.CAPABILITY, options); 


    driver = new RemoteWebDriver(new URL("http://192.168.1.205:4444/wd/hub"), capabilities); 
    driver.get("http://google.com"); 
    System.out.println(driver.getTitle()); 
       } 
} 

ERROR(。私は本当にすることになって問題が多分driver.versionが不明であり、それが問題であるかを把握することはできません。このことから?):

NODEコンソールで
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService 
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:40.131Z' 
System info: host: 'DESKTOP-BKIG71Q', ip: '192.168.1.126', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144' 
Driver info: driver.version: unknown 
Command duration or timeout: 84 milliseconds 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) 
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53) 
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91) 
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359) 
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) 
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source) 
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source) 
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source) 
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source) 
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) 
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source) 
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source) 
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source) 
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:362) 
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:217) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153) 
    at selenium.FromHub.main(FromHub.java:40) 
Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService 
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:40.131Z' 
System info: host: 'DESKTOP-BKIG71Q', ip: '192.168.1.126', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144' 
Driver info: driver.version: unknown 
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z' 
System info: host: 'DESKTOP-RMS16L0', ip: '192.168.1.205', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_73' 
Driver info: driver.version: unknown 
    at org.openqa.selenium.remote.server.ServicedSession$Factory.lambda$new$0(ServicedSession.java:163) 
    at org.openqa.selenium.remote.server.ServicedSession$Factory.apply(ServicedSession.java:173) 
    at org.openqa.selenium.remote.server.ActiveSessionFactory.lambda$createSession$16(ActiveSessionFactory.java:171) 
    at java.util.Optional.map(Unknown Source) 
    at org.openqa.selenium.remote.server.ActiveSessionFactory.createSession(ActiveSessionFactory.java:171) 
    at org.openqa.selenium.remote.server.commandhandler.BeginSession.execute(BeginSession.java:72) 
    at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0(WebDriverServlet.java:232) 
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 

エラー(それはここのように感じ、すべてが正常である多分私はちょうど良いまだということを知りません。。):

10:50:01.362 INFO - Binding default provider to: org.openqa.selenium.chrome.ChromeDriverService 
10:50:01.362 INFO - Found handler: [email protected]d88ce 
10:50:01.366 INFO - /session: Executing POST on /session (handler: BeginSession) 
10:50:01.373 INFO - Capabilities are: Capabilities {goog:chromeOptions={args=[], extensions=[], binary=D:\Projektek\Selenium\chrom..., }, browserName=chrome, } 
10:50:01.375 INFO - Capabilities {goog:chromeOptions={args=[], extensions=[], binary=D:\Projektek\Selenium\chrom..., }, browserName=chrome, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService) 
10:50:01.377 INFO - Capabilities {goog:chromeOptions={args=[], extensions=[], binary=D:\Projektek\Selenium\chrom..., }, browserName=chrome, } matched class org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService) 

あなただけでこれらを助けてくれることを願っています。それ以上のことが必要な場合は教えてください。ありがとう!

答えて

0

私はあなたのコード(でもない、必要なライン)と間違って同じ問題が、何も直面していない午前:

私は別のパスからのノードを開始しようとしたときに、問題が明らかにされ
options.setBinary(new File("D:\\Projektek\\Selenium\\chromedriver.exe")); 

。 用途:

E:\Testing\Automation> java -jar selenium-server-standalone-3.6.0.jar -role node -hub http: // localhost: 4444/grid/register 

の代わり:

C:\Users\Nabil> java -jar "E:\Testing\Automation\selenium-server-standalone-3.6.0.jar" -role node -hub http: // localhost: 4444/grid/register 
関連する問題