gpt4 book ai didi

java - CreatePlatformSocket() 返回错误 : An invalid argument was supplied. 端口不可用。在 Chrome 上运行 selenium 代码时退出...

转载 作者:太空宇宙 更新时间:2023-11-04 10:28:57 25 4
gpt4 key购买 nike

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

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 进程无法绑定(bind)到系统内分配的空闲端口。

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

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

据观察,当 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 级别。 (as per ChromeDriver v2.38 release notes)
  • 通过IDE清理您的项目工作区,并仅使用所需的依赖项重建项目。
  • 使用CCleaner工具可以清除执行测试套件之前和之后的所有操作系统杂务。
  • 如果您的基本网络客户端版本太旧,请通过 Revo Uninstaller 卸载它并安装最新的 GA 和已发布版本的Web 客户端
  • 重新启动系统以释放端口。
  • 执行您的@Test

关于java - CreatePlatformSocket() 返回错误 : An invalid argument was supplied. 端口不可用。在 Chrome 上运行 selenium 代码时退出...,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50255464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com