在使用docker-compose在网格上动态执行我的套件时,我得到了以下异常stacktrac:
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.
03:52:47 Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
03:52:47 System info: host: 'ip-10-33-0-63', ip: '10.33.0.63', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-1069-aws', java.version: '1.8.0_151'
03:52:47 Driver info: driver.version: RemoteWebDriver
03:52:47 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)
03:52:47 at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
03:52:47 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
03:52:47 at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
03:52:47 at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
03:52:47 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
03:52:47 at java.lang.reflect.Method.invoke(Method.java:498)
03:52:47 at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:131)
03:52:47 at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:61)
03:52:47 at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:511)
03:52:47 at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:241)
03:52:47 at org.testng.internal.Invoker.invokeMethod(Invoker.java:581)
03:52:47 at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:792)
03:52:47 at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1103)
03:52:47 at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:140)
03:52:47 at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:122)
03:52:47 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
03:52:47 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
03:52:47 at java.lang.Thread.run(Thread.java:748)
03:52:47 Caused by: java.net.ConnectException: Failed to connect to /10.33.0.220:4444
03:52:47 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
03:52:47 at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:165)
03:52:47 at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
03:52:47 at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
03:52:47 at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
03:52:47 at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
03:52:47 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03:52:47 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
03:52:47 at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
03:52:47 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03:52:47 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
03:52:47 at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
03:52:47 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03:52:47 at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
03:52:47 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
03:52:47 at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
03:52:47 at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
03:52:47 at okhttp3.RealCall.execute(RealCall.java:77)
03:52:47 at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:103)
03:52:47 at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:105)
03:52:47 at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
03:52:47 at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
03:52:47 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
03:52:47 Caused by: java.net.ConnectException: Connection refused (Connection refused)
03:52:47 at java.net.PlainSocketImpl.socketConnect(Native Method)
03:52:47 at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
03:52:47 at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
03:52:47 at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
03:52:47 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
03:52:47 at java.net.Socket.connect(Socket.java:589)
03:52:47 at okhttp3.internal.platform.Platform.connectSocket(Platform.java:129)
03:52:47 at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:245)
这是在执行以下操作时发生的:
return (new RemoteWebDriver(new URL(url), new FirefoxOptions()));
chrome也是如此。我最近将selenium升级到最新版本,即3.141.59。
docker组合。yml
是:
version: "3"
services:
selenium-hub:
image: selenium/hub:3.141.59-bismuth
container_name: selenium-hub
ports:
- "4444:4444"
environment:
- GRID_BROWSER_TIMEOUT=30
chrome:
image: selenium/node-chrome:3.141.59-bismuth
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
firefox:
image: selenium/node-firefox:3.141.59-bismuth
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
volumes:
- "/dev/shm:/dev/shm"
这在Jenkins和我从cmd在我的系统中执行时都发生了。我不确定这个问题是与selenium还是网络有关。如果有其他解决方案的链接,请在此分享。预先感谢任何帮助。
更新和编辑:
启动:
1)通过mvn干净安装构建项目(使用maven-Assembly-plugin)-DskipTest=true
2)启动网格:sudo docker-compose up-d--size chrome=5--caleFirefox=3
3) 运行可执行 jar。
4)删除网格:sudo docker-compose down
更新:
添加集线器配置:
Config for the hub :
browserTimeout : 30
debug : false
jettyMaxThreads : -1
host : 192.168.80.2
port : 4444
role : hub
timeout : 1800
cleanUpCycle : 5000
capabilityMatcher : org.openqa.grid.internal.utils.DefaultCapabilityMatcher
newSessionWaitTimeout : -1
throwOnCapabilityNotPresent : true
registry : org.openqa.grid.internal.DefaultGridRegistry
The final configuration comes from:
the default :
browserTimeout : 0
debug : false
host : 0.0.0.0
port : 4444
role : hub
timeout : 1800
cleanUpCycle : 5000
capabilityMatcher : org.openqa.grid.internal.utils.DefaultCapabilityMatcher
newSessionWaitTimeout : -1
throwOnCapabilityNotPresent : true
registry : org.openqa.grid.internal.DefaultGridRegistry
updated with command line options:
-role hub -hubConfig /opt/selenium/config.json
and configuration loaded from /opt/selenium/config.json:
{
"host": "0.0.0.0",
"port": 4444,
"role": "hub",
"maxSession": 5,
"newSessionWaitTimeout": -1,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"jettyMaxThreads": -1,
"cleanUpCycle": 5000,
"browserTimeout": 30,
"timeout": 1800,
"debug": false
}
添加节点配置:
browserTimeout: 30
debug: false
jettyMaxThreads: -1
host: 192.168.80.6
port: 5555
role: node
timeout: 1800
cleanUpCycle: 5000
maxSession: 1
capabilities: Capabilities {applicationName: , browserName: chrome, maxInstances: 1, platform: LINUX, platformName: LINUX, seleniumProtocol: WebDriver, server:CONFIG_UUID: d949d886-61f4-4a3a-93f9-c2a..., version: 70.0.3538.110}
downPollingLimit: 2
hub: http://selenium-hub:4444/grid/register
id: http://192.168.80.6:5555
nodePolling: 5000
nodeStatusCheckTimeout: 5000
proxy: org.openqa.grid.selenium.proxy.DefaultRemoteProxy
register: true
registerCycle: 5000
remoteHost: http://192.168.80.6:5555
unregisterIfStillDownAfter: 60000
我通过遵循本文的最后一条评论解决了同样的问题。Docker 容器无法访问本地主机端口 4444。为什么呢?
在您的docker compose中。服务下的yaml文件,其中您的集线器是集线器的名称。使用该名称来制定remotewebdriver的url。
刚将“localhost:4444/wd/hub”更改为“seleniumhub:4444/wd/hub”
此错误消息...
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.
03:52:47 Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
03:52:47 System info: host: 'ip-10-33-0-63', ip: '10.33.0.63', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-1069-aws', java.version: '1.8.0_151'
03:52:47 Driver info: driver.version: RemoteWebDriver
...意味着WebDriver无法启动/生成新的Remote teWebDriver会话。
我没有在您的配置或代码行中看到任何重大问题。但是,您的主要问题似乎是您正在使用的二进制文件版本之间的不兼容性,如下所示:
测试
我正在尝试使用Selenium Grid运行一个简单的程序(事先不了解Selenium Grid),出现如下错误: 线程“main”org.openqa.selenium.remote中出现异常。UnreachableBrowserException:无法启动新会话。可能的原因是远程服务器地址无效或浏览器启动失败。构建信息:版本:“未知”,版本:“未知”,时间:“未知”系统信息:主机:“DEL1-
我是硒的新手。能够在Ubuntu上配置selenium设置。配置详情如下: 谷歌浏览器68.0.3440.84 但每次跑步我都会发现詹金斯的错误: 请推荐我。
我是硒的新手。尝试以下代码,它适用于Firefox。当我尝试Safari时,出现错误。 硒Safari 任何指针如何解决此问题。
后我Chrome版本更新到96.0.4664.55我不能运行我的硒脚本和得到以下错误 我正在使用WebDriverManager。chromedriver()。设置(); 我看到chromedriver的版本是45,我的浏览器是96.0.4664.55。这是导致此问题的原因吗。我试图搜索55版本的驱动程序,但找不到https://chromedriver.chromium.org/download
我正在尝试在Safari上运行我的Selenium测试。我可以在FireFox和IE上运行我的测试,它运行良好,但在Safari上不行。所以可能有人遇到了同样的问题,可以告诉我为什么它不起作用,是的,我已经将WebDriver添加到SafariExtencions:http://prntscr.com/809miw 我有这个错误: 以下是我选择浏览器的方式:
我对Selenium是新手,我用Python编程了一个基本的机器人来玩。第一行代码刚刚启动web浏览器: 它工作正常,允许我完成和测试机器人的其余部分,该部分登录帐户并下载文档。 然后我换成了Java(我需要的最后一种语言),并重复了编程,结果非常简单。初始命令为: 代码对于IDE(Intellij)来说很好,但在执行时会出现错误 在端口51171上启动ChromeDriver 98.0.4758