CreatePlatformSocket() 返回了一个错误:提供了无效的参数.端口不可用.退出..在Chrome上运行



我正在尝试运行以下代码:

package automationFramework;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import appModules.SignIn_Action;
import utility.Constant;
import utility.ExcelUtils;
public class Apache_POI_TC {
private static WebDriver driver=null;
public static void main(String[] args) throws Exception {
ExcelUtils.setExcelFile(Constant.Path_TestData + Constant.File_TestData,"Sheet1");
System.setProperty("webdriver.chrome.driver","F:\Chromedriver\chromedriver_win32\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get(Constant.URL);
SignIn_Action.execute(driver);
System.out.println("Login Successfully, now it is the time to Log Off buddy.");
driver.quit();
ExcelUtils.setCellData("Pass", 1, 3);
}}

但是得到错误:

Starting ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) on port 17873
Only local connections are allowed.
[1525873930.811][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
[1525873930.816][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
Port not available. Exiting...
May 09, 2018 7:22:30 PM org.openqa.selenium.os.UnixProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
Exception in thread "main" 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: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'VAPW00000001503', ip: '10.96.62.163', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
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:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
at automationFramework.Apache_POI_TC.main(Apache_POI_TC.java:25)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'VAPW00000001503', ip: '10.96.62.163', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:178)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
... 7 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:17873/status] to be available after 20004 ms
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:175)
... 10 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)
... 11 more
Caused by: java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:130)
... 12 more

拾取_JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

请建议我如何解决这个问题

此错误消息...

Port not available. Exiting...
May 09, 2018 7:22:30 PM org.openqa.selenium.os.UnixProcess checkForError

。意味着操作系统 Unix 进程无法绑定到系统中分配的可用端口。

根据讨论Getting Invalid port error.错误"无效端口。分配给 chromedriver 的端口小于 0 或大于 65535 时,将出现"正在退出..."。

但是,从历史上看,根据讨论:

  • CreatePlatformSocket(( 返回了一个错误:提供了无效的参数。(0x2726( 端口不可用。退出。。。使用铬驱动程序和硒 3.2
  • CreatePlatformSocket(( 返回了一个错误:提供了无效的参数。(0x27t6( 端口不可用。退出。。。in Selenium Webdriver

据观察,当ChromeDriverGeckoDriver通过网络共享时,在初始化浏览器客户端时,观察到以下错误:

  • 样本 A:

    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)
    org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
    
  • 样本 B:

    [0.147][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726) 
    Port not available. Exiting...
    
  • 样本 C:

    [1525873930.816][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
    Port not available. Exiting...
    May 09, 2018 7:22:30 PM org.openqa.selenium.os.UnixProcess checkForError
    SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    Exception in thread "main" 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.
    
  • 甚至:

    //chromedriver
    [1530079175.164][SEVERE]: CreatePlatformSocket() returned an error: An invalid argument was supplied. (0x2726)
    [1530079175.165][INFO]: listen on IPv4 failed with error ERR_INVALID_ARGUMENT
    //geckodriver
    An invalid argument was supplied. (os error 10022)
    //IEDriverServer
    Failed to start the server with: port = '2305', host = '', log level = '', log file = '', whitelisted ips = ''
    

溶液

  • 确保ChromeDriverGeckoDriver放置在主机的本地驱动器中。
  • 通过CLI执行netstat命令以查看是否已达到可能打开的连接限制,或检查给定端口上是否有另一个应用程序正在运行。
  • 检查您的防火墙设置,防火墙配置很有可能导致问题。
  • ChromeDriver升级到当前的ChromeDriver v2.38级别。
  • Chrome 版本保持在Chrome v66.x级别。(根据ChromeDriver v2.38发行说明(
  • 通过IDE清理项目工作中心,并仅使用所需的依赖项重新生成项目。
  • 使用CCleaner工具在执行测试套件之前和之后清除所有操作系统杂务。
  • 如果您的基本 Web 客户端版本太旧,请通过Revo 卸载程序将其卸载,并安装最新的 GA 和已发布版本的Web 客户端
  • 重新启动系统以释放端口。
  • 执行您的@Test

相关内容

  • 没有找到相关文章

最新更新