![](/img/trans.png)
[英]error“ org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/” with GeckoDriver and Firefox
[英]WebDriverException: java.net.ConnectException: Failed to connect to localhost error with Selenium 3 and chromedriver on MacOS
嗨,我有这个奇怪的问题。 我无法在Mac上使用chromedriver进行测试。 我在这里搜索了每个可能的角落,似乎没有人帮忙。 我的浏览器已启动,但它在driver.get(url)
之前冻结。
我的环境:MacOS High Sierra,最新的chromedriver,截至2018年3月12日,最新的硒3.10,最新的TestNG 6.14
我的代码:
public class Temp {
@Test()
public void test1() {
System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver");
ChromeOptions options = new ChromeOptions();
options.addArguments("--test-type");
options.addArguments("ignore-certificate-errors");
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://www.google.co.in/");
driver.quit();
}
}
我得到的例外是:
[RemoteTestNG]检测到TestNG版本6.14.2在端口34979上启动ChromeDriver(v2.9.248307)[warn] kq_init:检测到破碎的kqueue; 不使用:未定义错误:0 2018年3月12日上午07时06分13秒org.openqa.selenium.remote.ProtocolHandshake了createSession信息:检测到的话:OSS失败:TEST1 org.openqa.selenium.WebDriverException:java.net.ConnectException :无法连接到localhost / 0:0:0:0:0:0:0:1:34979构建信息:版本:'3.10.0',修订版:'176b4a9',时间:'2018-03-02T19: 03:16.397Z'系统信息:主机:'sandeep-MacBook-Pro.local',ip:'192.168.0.100',os.name:'Mac OS X',os.arch:'x86_64',os.version: '10 13.3' ,java.version: '1.8.0_101' 驱动程序信息:driver.version:RemoteWebDriver在org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)在org.openqa.selenium .remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658)org.openqa.selenium.remote.RemoteWebDriver $ RemoteWebDriverOptions $ RemoteWindow.maximize(RemoteWebDriver) .java:892)at com.pareek.framework.tests.Temp.test1(Temp.java:22)at su n.reflect.NativeMethodAccessorImpl.invoke0(本地方法)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method。在org.testng.internal.Invoker的org.testng.internal.invokeMethod(Invoker.java:580)的org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)中调用(Method.java:498) .invokeTestMethod(Invoker.java:716)org.testng.internal.InvokeTestMethods(Invoker.java:988)org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)atg.testng.internal。 testMethodWorker.run(TestMethodWorker.java:109)org.testng.TestRunner.run(TestRunner.java:648)org.test.TestRunner.run(TestRunner.java:505)org.testng.SuiteRunner.runTest(SuiteRunner)上的org.testng.TestRunner.privateRun(TestRunner.java:648) .java:455)org.testng.SuiteRunner.run顺序(SuiteRunner.java:450)org.testng.SuiteRunner.privateRun(SuiteRunner.j) AVA:415)在org.testng.SuiteRunner.run(SuiteRunner.java:364)在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)在org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)org.testng.TestNG.runSuitesLocally(TestNG.java:1137)org.testng.TestNG.runSuites(TestNG.java:1049)atg.testng.TestNG .run(TestNG.java:1017)org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)位于org.testng.remote的org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)。 RemoteTestNG.main(RemoteTestNG.java:77)引起:java.net.ConnectException:无法连接到localhost / 0:0:0:0:0:0:0:1:34979 at okhttp3.internal.connection.RealConnection .connectSocket(RealConnection.java:240)在okhttp3.internal.connection.RealConnection.connect(RealConnection.java:158)在okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256)在okhttp3.internal.connection。 StreamAllocation。 在OKhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113)的okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)的okhttp3.internal.http.RealInterceptorChain中的findHealthyConnection(StreamAllocation.java:134)在okhttp3.internal.http的okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)的okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)中.proceed(RealInterceptorChain.java:147)。在okhttp3.internal.http的okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)的okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)中的RealInterceptorChain.proceed(RealInterceptorChain.java:147)位于okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)的okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)中的.RealInterceptorChain.proceed(RealInterceptorChain.java:147) p3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)位于org.openqa.selenium.remote的okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)okhttp3.RealCall.execute(RealCall.java:77) .internal.OkHttpClient.execute(OkHttpClient.java:101)org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:157)org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java) :83)... 29更多引起:java.net.ConnectException:java.net上的java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)上的java.net.PlainSocketImpl.socketConnect(Native Method)连接被拒绝java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)java.net.SocksSocketImpl.connect(AbstractPlainSocketImpl.java:188)上的.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) Socket.java:589)在okhttp3.internal.platform.Platform.connectSocket(Platfor m.java:125)okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:238)... 49更多
===============================================
默认测试
>测试运行:1,失败:1,跳过:0
===============================================默认套件
总测试运行:1,失败:1,跳过:0
编辑:如果我删除注释掉driver.manage().window().maximize();
功能,异常日志如下:
[RemoteTestNG]检测到TestNG版本6.14.2在端口22528上启动ChromeDriver(v2.9.248307)[warn] kq_init:检测到破碎的kqueue; 不使用:未定义错误:0月12日,2018年7:29:29 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO:检测到的方言:OSS FAILED:test1 org.openqa.selenium.WebDriverException:未知错误:运行时。 executionContextCreated具有无效的'context':{“auxData”:{“frameId”:“8045B2382F1BD52FB2B8744951B53B43”,“isDefault”:true},“id”:1,“name”:“”,“origin”:“://” (会话信息:chrome = 65.0.3325.146)(驱动程序信息:chromedriver = 2.9.248307,platform = Mac OS X 10.13.3 x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:0毫秒构建信息:版本:'3.10.0',修订版:'176b4a9',时间:'2018-03-02T19:03:16.397Z'系统信息:主机:'sandeep-MacBook-Pro.local',ip:'192.168 .0.100',os.name:'Mac OS X',os.arch:'x86_64',os.version:'10 .13.3',java.version:'1.8.0_101'驱动程序信息:org.openqa.selenium。 chrome.ChromeDriver Capabilities {acceptSslCerts:true,applicationCacheEnabled:false,browserConnectionEnabled:false,browserName :chrome,chrome:{userDataDir:/ var / folders / 3t / p4sy21xx2cb ...},cssSelectorsEnabled:true,databaseEnabled:false,handlesAlerts:true,javascriptEnabled:true,locationContextEnabled:true,nativeEvents:true,platform:MAC,platformName :MAC,rotate:false,takesHeapSnapshot:true,takesScreenshot:true,version:65.0.3325.146,webStorageEnabled:true}会话ID:2301d210d1a4f56bab558a8111d856c4 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance( NativeConstructorAccessorImpl.java:62)位于org.openqa.selenium.remote.ErrorHandler.createThrowable的java.lang.reflect.Constructor.newInstance(Constructor.java:423)中的sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) (ErrorHandler.java:214)org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpRe) sponserCodec.java:40)org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)atg.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)at org .openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:160)org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:601)org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:325)位于sun.reflect的com.pareek.framework.tests.Temp.test1(Temp.java:24)。 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)中的NativeMethodAccessorImpl.invoke0(Native Method)位于sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)的java.lang.reflect.Method.invoke(方法。 java:498)at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124 )org.testng.internal.InvokeTethod(Invoker.java:570)org.stng.internal.InvokeTestMethod上的org.testng.internal.Invoker.invokeMethod(Invoker.java:580)org.test.internal.InvokeTestMethods(Invoker.java: 988)org.testng.inv.TestMethods.TestMethodWorker.run(TestMethodWorker.java:109)org.test.TestRunner.privateRun(TestRunner.java:648)上的org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) )在org.testng.TestRunner.run(TestRunner.java:505)在org.testng.SuiteRunner.runTest(SuiteRunner.java:455)在org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)在org.testng .OiteRunner.privateRun(SuiteRunner.java:415)org.testng.SuiteRunner.run(SuiteRunner.java:364)org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)at org.testng.SuiteRunnerWorker.run( SuiteRunnerWorker.java:84)org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)org.testng.TestNG.runSuitesLocally(TestNG.java:1137)atg.testng.TestNG.runSuites(TestNG.java:1049) )在org.testn g.TestNG.run(TestNG.java:1017)位于org.testng的org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) .remote.RemoteTestNG.main(RemoteTestNG.java:77)
===============================================
默认测试
>测试运行:1,失败:1,跳过:0
===============================================默认套件
总测试运行:1,失败:1,跳过:0
附加信息:我试图通过使用旧版本的chromedriver,旧版本的TestNG,旧版本的selenium进行回归,但似乎没有一个工作。
提前致谢。
错误说明了一切:
[RemoteTestNG] detected TestNG version 6.14.2 Starting ChromeDriver (v2.9.248307) on port 34979
[warn] kq_init: detected broken kqueue; not using.: Undefined error: 0 Mar 12, 2018 7:06:13 AM
org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS FAILED: test1
org.openqa.selenium.WebDriverException: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:34979
Build info: version: '3.10.0', revision: '176b4a9', time: '2018-03-02T19:03:16.397Z'
System info: host: 'sandeep-MacBook-Pro.local', ip: '192.168.0.100', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.3', java.version: '1.8.0_101'
您的主要问题是您使用的二进制文件之间的版本兼容性如下:
支持Chrome v31-34
因此, JDK v8u101 , Selenium Client v3.10.0 , ChromeDriver版本( v2.9 )与当前Chrome浏览器版本( v65.0 )之间明显不匹配
@Test
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.