无法使用Selenium和Java在集线器中创建节点

时间:2016-05-03 08:38:14

标签: java selenium selenium-webdriver

我有一个Java Web应用程序,我在其中集成了一些Selenium代码,它基本上完成了以下工作:当我从远程系统访问URL时,它会在我的服务器上打开浏览器。

我正在尝试以编程方式在集线器上创建节点。已成功创建集线器,但未创建该节点。

这是我的代码:

try {

    GridHubConfiguration config = new GridHubConfiguration();
    config.setHost("localhost");
    config.setPort(4444);

    Hub  hub = new Hub(config);
    hub.start();

    SelfRegisteringRemote node = null;
    RegistrationRequest req = new RegistrationRequest();

    // Create capabilities instance
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName(DesiredCapabilities.firefox().getBrowserName());
    capabilities.setCapability(RegistrationRequest.MAX_INSTANCES,5);

    // Set configurations for registration request
    Map<String, Object> nodeConfig = new HashMap<String, Object>();
    nodeConfig.put(RegistrationRequest.AUTO_REGISTER, true);
    nodeConfig.put(RegistrationRequest.HUB_HOST, hub.getHost());
    nodeConfig.put(RegistrationRequest.HUB_PORT, hub.getPort());
    nodeConfig.put(RegistrationRequest.PORT, 5555);
    URL remoteURL = null;

    remoteURL = new URL("http://" + hub.getHost() + ":" + 8080);
    nodeConfig.put(RegistrationRequest.PROXY_CLASS,
            "org.openqa.grid.selenium.proxy.DefaultRemoteProxy");
    nodeConfig.put(RegistrationRequest.MAX_SESSION, 5);
    nodeConfig.put(RegistrationRequest.CLEAN_UP_CYCLE, 2000);
    nodeConfig.put(RegistrationRequest.REMOTE_HOST, remoteURL);
    nodeConfig.put(RegistrationRequest.MAX_INSTANCES, 5);

    String nodeUrl = "http://"+hub.getHost()+":8080/wd/hub";  
    DesiredCapabilities capability = DesiredCapabilities.chrome();
    driver = new RemoteWebDriver(new URL(nodeUrl),capability);
    driver.get("http://www.facebook.com");

} catch (Exception e) {
    e.printStackTrace();
}

这就是我得到的:

11:44:37,347 INFO  [org.seleniumhq.jetty9.util.log] (http-localhost-127.0.0.1-8383-2) Logging initialized @22800ms
11:44:37,363 INFOS [org.openqa.grid.web.Hub] (http-localhost-127.0.0.1-8383-2) Will listen on 4444
11:44:37,425 INFOS [org.openqa.grid.web.Hub] (http-localhost-127.0.0.1-8383-2) Will listen on 4444
11:44:37,431 INFO  [org.seleniumhq.jetty9.server.Server] (http-localhost-127.0.0.1-8383-2) jetty-9.2.z-SNAPSHOT
11:44:37,467 INFO  [org.seleniumhq.jetty9.server.handler.ContextHandler] (http-localhost-127.0.0.1-8383-2) Started o.s.j.s.ServletContextHandler@40ce{/,null,AVAILABLE}
11:44:37,477 INFO  [org.seleniumhq.jetty9.server.ServerConnector] (http-localhost-127.0.0.1-8383-2) Started ServerConnector@5677ae{HTTP/1.1}{0.0.0.0:4444}
11:44:37,478 INFO  [org.seleniumhq.jetty9.server.Server] (http-localhost-127.0.0.1-8383-2) Started @22933ms
11:44:38,854 ERROR [stderr] (http-localhost-127.0.0.1-8383-2) org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
11:44:38,856 ERROR [stderr] (http-localhost-127.0.0.1-8383-2) Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
11:44:38,858 ERROR [stderr] (http-localhost-127.0.0.1-8383-2) System info: host: 'xperience-PC', ip: '10.61.192.3', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_79'
11:44:38,860 ERROR [stderr] (http-localhost-127.0.0.1-8383-2) Driver info: driver.version: RemoteWebDriver
11:44:38,861 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
11:44:38,863 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
11:44:38,864 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
11:44:38,866 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:158)
11:44:38,868 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at tn.orange.xperience.open.site.OpenSite.openSiteEjb(OpenSite.java:705)
11:44:38,869 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:44:38,871 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
11:44:38,872 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
11:44:38,874 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.lang.reflect.Method.invoke(Unknown Source)
11:44:38,875 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
11:44:38,878 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,879 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
11:44:38,881 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
11:44:38,883 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,885 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
11:44:38,887 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,888 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
11:44:38,890 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,892 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
11:44:38,893 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
11:44:38,896 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,897 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
11:44:38,899 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,901 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
11:44:38,903 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
11:44:38,904 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
11:44:38,906 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,907 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
11:44:38,910 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,911 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
11:44:38,913 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,915 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
11:44:38,917 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,918 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
11:44:38,921 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,922 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
11:44:38,924 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,926 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
11:44:38,927 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
11:44:38,929 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)
11:44:38,931 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
11:44:38,932 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
11:44:38,934 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
11:44:38,936 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at tn.orange.xperience.open.site.OpenSiteLocal$$$view3.openSiteEjb(Unknown Source)
11:44:38,937 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at beans.OpenSiteBean.openSite(OpenSiteBean.java:72)
11:44:38,939 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:44:38,940 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
11:44:38,942 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
11:44:38,943 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.lang.reflect.Method.invoke(Unknown Source)
11:44:38,945 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
11:44:38,946 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
11:44:38,948 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
11:44:38,950 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
11:44:38,952 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
11:44:38,953 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at javax.faces.component.UICommand.broadcast(UICommand.java:315)
11:44:38,955 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
11:44:38,956 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
11:44:38,958 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
11:44:38,960 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
11:44:38,961 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
11:44:38,963 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
11:44:38,964 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
11:44:38,966 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
11:44:38,968 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
11:44:38,970 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
11:44:38,971 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
11:44:38,973 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
11:44:38,975 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
11:44:38,977 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
11:44:38,978 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
11:44:38,980 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
11:44:38,982 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
11:44:38,983 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
11:44:38,985 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
11:44:38,987 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.lang.Thread.run(Unknown Source)
11:44:38,989 ERROR [stderr] (http-localhost-127.0.0.1-8383-2) Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1] failed: Connection refused: connect
11:44:38,991 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
11:44:38,993 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
11:44:38,995 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
11:44:38,997 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
11:44:38,998 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
11:44:39,000 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
11:44:39,001 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
11:44:39,003 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
11:44:39,005 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
11:44:39,006 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
11:44:39,008 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:144)
11:44:39,010 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:90)
11:44:39,012 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
11:44:39,013 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
11:44:39,015 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   ... 74 more
11:44:39,016 ERROR [stderr] (http-localhost-127.0.0.1-8383-2) Caused by: java.net.ConnectException: Connection refused: connect
11:44:39,018 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
11:44:39,019 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
11:44:39,021 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
11:44:39,022 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
11:44:39,024 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.net.PlainSocketImpl.connect(Unknown Source)
11:44:39,025 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.net.SocksSocketImpl.connect(Unknown Source)
11:44:39,026 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at java.net.Socket.connect(Unknown Source)
11:44:39,028 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:74)
11:44:39,029 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
11:44:39,031 ERROR [stderr] (http-localhost-127.0.0.1-8383-2)   ... 87 more

0 个答案:

没有答案