Я получаю ошибку ниже, когда я запускаю свой код селена.Может ли кто-нибудь помочь мне решить эту проблему:
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 129.633 sec <<< FAILURE!
GoogleTest(gridtest.GridTest) Time elapsed: 128.291 sec <<< FAILURE!
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.**
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'XXXXXX', ip: 'XXXXXX', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-696.23.1.el6.x86_64', java.version: '1.8.0_77'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:607)
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 gridtest.GridTest.GoogleTest(GridTest.java:48)
**Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to xxx.xxx.xxx.xxx:4444 [xxx.xxx.xxx.xxx/yyy.yyy.yyy.yyy, xxx.xxx.xxx.xxx/yyy.yyy.yyy.yyy] failed: Connection timed out**
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:157)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:138)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:86)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:337)
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)
... 38 more
Caused by: java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 53 more
Ниже приведена конфигурация моей сетки и узла.
У меня установлен подключаемый модуль Jenkins с Selenium.Итак, мой концентратор запущен и работает на моей машине Jenkins.
Хост: xxx.xxx.xxx.xxx Порт: 4444
Теперь с моей машины Node я запустил автономный сервер selenium с ролью узлаи зарегистрировал плюшку
C:\Temp>java -jar selenium-server-standalone-3.12.0.jar -role node -hub http://xxx.xxx.xxx.xxx:4444/grid/register -port 17946
Как только узел запущен, я вижу в консоли узла, что узел зарегистрирован в Grid.А также в Jenkins Selenium Grid я вижу узел, подключенный в зарегистрированных удаленных компонентах.
В конфигурации Selenium Grid я также настроил указанный выше порт с chrome и запустил узел в конфигурации, соответствующей узлам.
Ниже приведеномой простой код:
System.out.println("I am in test");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
// say you use the redhat5 label to indicate RHEL5 and the amd64 label to specify the architecture
//capabilities.setCapability("jenkins.label","RHEL6");
//capabilities.setCapability("jenkins.label","redhat5 && amd64");
// Say you want a specific node to thread your request, just specify the node name (it must be running a selenium configuration though)
//capabilities.setCapability("jenkins.nodeName","(master)");
//capabilities.setPlatform(Platform.WINDOWS);
//System.setProperty("webdriver.chrome.driver", "Drivers"+File.separator+"chromedriver.exe");
//System.setProperty("webdriver.chrome.driver", "C:\\chromedriver\\chromedriver.exe");
System.out.println("I am after setting chromedriver path ");
remoteWD = new RemoteWebDriver(new URL("http://xxx.xxx.xxx.xxx:4444/wd/hub"), capabilities);
//remoteWD = new ChromeDriver();
System.out.println("I am after RMD");
remoteWD.get("http://www.google.com");
WebElement element = remoteWD.findElement(By.name("q"));
element.sendKeys("Selenium WebDriver");
element.submit();
Thread.sleep(10000);
System.out.println(remoteWD.getTitle());
remoteWD.quit();