我正在尝试运行以下代码:
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
请建议我如何解决这个问题
答案 0 :(得分:0)
此错误消息......
Port not available. Exiting...
May 09, 2018 7:22:30 PM org.openqa.selenium.os.UnixProcess checkForError
...意味着 OS Unix进程无法绑定到系统中指定的空闲端口。
根据讨论Getting Invalid port error.
,当分配给chromedriver的端口小于0或大于65535时,会出现错误`“无效端口。退出...” 。
但是,根据讨论的历史:
有人观察到,当通过网络共享 ChromeDriver 和 GeckoDriver 时,在初始化浏览器客户端时会发现以下错误:
样本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 = ''
netstat
命令,查看是否已达到可能的打开连接限制,或检查给定端口上是否有其他应用程序在运行。@Test
。