首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CreatePlatformSocket()返回一个错误:提供了一个无效的参数。港口不可用。正在退出...在Chrome上运行selenium代码时

CreatePlatformSocket()返回一个错误:提供了一个无效的参数。港口不可用。正在退出...在Chrome上运行selenium代码时
EN

Stack Overflow用户
提问于 2018-05-09 14:06:46
回答 1查看 2.4K关注 0票数 1

我试图运行以下代码:

代码语言:javascript
运行
复制
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);
     }}

但犯了错误:

代码语言:javascript
运行
复制
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

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

EN

回答 1

Stack Overflow用户

发布于 2018-05-09 14:23:53

这个错误信息..。

代码语言:javascript
运行
复制
Port not available. Exiting...
May 09, 2018 7:22:30 PM org.openqa.selenium.os.UnixProcess checkForError

...implies表示OS Unix进程无法绑定到系统中分配的空闲端口。

根据讨论获得无效端口错误。,错误‘“无效端口。退出.当分配给色度驱动程序的端口小于0或大于65535时发生

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

已经注意到,当ChromeDriver和GeckoDriver通过网络共享时,在初始化浏览器客户端时会观察到以下错误:

  • 样本A: 在端口12121上启动ChromeDriver 2.28.455520 (cc17746adff54984afff480136733114c6b3704b)只允许本地连接。0.023: CreatePlatformSocket()返回一个错误:提供了一个无效的参数。(0x2726) 0.023: CreatePlatformSocket()返回一个错误:提供了一个无效的参数。(0x2726)没有端口。正在退出...2017年3月11日9:13:06 PM org.openqa.selenium.os.UnixProcess checkForError checkForError: org.apache.commons.exec.ExecuteException:进程退出时出错:1(退出值: 1) org.openqa.selenium.WebDriverException:超时等待驱动服务器启动。
  • 样本B: 0.147: CreatePlatformSocket()返回一个错误:提供了一个无效的参数。(0x2726)没有端口。正在退出...
  • 样本C: 1525873930.816: CreatePlatformSocket()返回一个错误:提供了一个无效的参数。(0x2726)没有端口。正在退出...2018年5月9日7:22:30 PM org.openqa.selenium.os.UnixProcess checkForError checkForError: org.apache.commons.exec.ExecuteException: Process退出时出错:1(退出值: 1)线程"main“checkForError中的异常无法启动新会话。可能的原因是远程服务器或浏览器启动失败的地址无效。
  • 甚至: //chromedriver 1530079175.164: CreatePlatformSocket()返回一个错误:提供了一个无效的参数。(0x2726) 1530079175.165:侦听IPv4失败,错误为ERR_INVALID_ARGUMENT //geckodriver,提供了一个无效的参数。(os错误10022) //IEDriverServer未能启动服务器:端口= '2305',主机= '',日志级别= '',日志文件= '',白化ips = '‘

解决方案

  • 确保ChromeDriver或GeckoDriver位于主机的本地驱动器中。
  • 通过CLI执行netstat命令,查看是否达到了可能打开的连接的限制,或者检查给定端口上是否有另一个应用程序正在运行。
  • 检查您的防火墙设置,有很大可能是防火墙配置可能导致问题。
  • 将ChromeDriver升级到当前的ChromeDriver v2.38级别。
  • 将Chrome版本保持在Chromev66.x级别。(根据ChromeDriver v2.38发布说明)
  • 通过IDE清理项目工作区,并仅使用所需的依赖项重新构建项目。
  • 使用https://www.ccleaner.com/ccleaner工具在执行测试套件之前和之后清除所有操作系统杂务。
  • 如果您的基本Web客户端版本太旧,那么通过https://www.revouninstaller.com/revo_uninstaller_free_download.html卸载它,并安装最新的GA和发布版本的Web。
  • 使用系统重新引导来释放端口。
  • 执行您的@Test
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50255464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档