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

bwntbbo3  于 2023-03-21  发布在  Go
关注(0)|答案(1)|浏览(65)

我无法启动 chrome (或任何其他浏览器)与 selenium 。相同的代码工作时,我从我的家庭电脑运行。所以我认为这与防火墙和安全设置。
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
4szc88ey

4szc88ey1#

我找出了错误的原因这是因为我的chromedriveriderexe在一个联网的驱动器上,而不是在浏览器运行测试的机器上。解决方法是将chromedriveriderexe移到C驱动器下。

相关问题