CreatePlatformSocket()返回错误:提供了无效的参数。 (0x2726)端口不可用。退出...与chromedriver和Selenium 3.2

时间:2017-03-12 02:28:47

标签: google-chrome selenium selenium-webdriver webdriver selenium-chromedriver

我无法使用selenium启动chrome(或任何其他浏览器)。 当我从家用电脑上运行时,相同的代码可以正常工作。所以我认为它与防火墙和安全设置有关。

selenium版本是3.2,Chrome驱动版本是2.28我也试过2.25(同样的错误)。使用的代码:

 System.setProperty("webdriver.chrome.driver", "K://browserdriver//chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");

错误讯息:

Starting ChromeDriver 2.28.455520 (cc17746adff54984afff480136733114c6b3704b) on port 12121
Only local connections are allowed.
[0.023][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
[0.023][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
Port not available. Exiting...
Mar 11, 2017 9:13:06 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
FAILED CONFIGURATION: @BeforeTest beforeTest
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.2.0', revision: '8c03df6b79', time: '2017-02-23 10:51:31 +0000'
System info: host: 'a1', ip: '', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_77'
Driver info: driver.version: ChromeDriver
	at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:180)
	at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:168)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167)
	at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
	at browesertest.NewTest.beforeTest(NewTest.java:23)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
	at org.testng.TestRunner.beforeRun(TestRunner.java:641)
	at org.testng.TestRunner.run(TestRunner.java:609)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
	at org.testng.SuiteRunner.run(SuiteRunner.java:240)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
	at org.testng.TestNG.run(TestNG.java:1031)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:24144/status] to be available after 20001 ms
	at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
	at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
	... 32 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
	at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:140)
	at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
	... 33 more
Caused by: java.util.concurrent.TimeoutException
	at java.util.concurrent.FutureTask.get(Unknown Source)
	at com.google.common.util.c

1 个答案:

答案 0 :(得分:4)

我找出了错误的原因;这是因为我的chromedriver.exe在网络驱动器上,而不是在机器上浏览器正在运行测试。解决方案是将chromedriver.exe移动到C盘下。