无效的端口.正在退出... org.openqa.selenium.os.OsProcess checkForError使用硒启动chrome时 [英] Invalid port. Exiting... org.openqa.selenium.os.OsProcess checkForError while launching chrome using selenium
问题描述
我正在使用硒服务器独立jar- 3.11.0,最新的ChromeDriver-2.36和 Chrome版本66.0.3359.139
I am using selenium server standalone jar- 3.11.0, latest ChromeDriver-2.36 and Chrome version 66.0.3359.139
我的代码
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class WebDriverBasics {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\surya\\Downloads\\Compressed\\chromedriver_win32_2\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.facebook.com");
driver.manage().window().maximize();
}
}
但是我无法启动chrome.its并给出以下错误消息
But i am unable to launch chrome.its giving below error
Invalid port. Exiting...
?? ??, ???? ??:??:?? ????????? org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
System info: host: 'DESKTOP-5GVJDVR', ip: '192.168.0.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:192)
at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:178)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:209)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:132)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at WebDriverBasics.main(WebDriverBasics.java:12)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:????/status] to be available after ????? ms
at
推荐答案
此错误消息...
Invalid port. Exiting...
?? ??, ???? ??:??:?? ????????? org.openqa.selenium.os.OsProcess checkForError
SEVERE: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
...表示 OsProcess 无法绑定到系统中分配的可用端口.
...implies that the OsProcess is unable to bind to the assigned free port within your system.
根据讨论 Getting Invalid port error.
> 和 Invalid port. Exiting...
"Invalid port. Exiting..." occurs when the port assigned to chromedriver is less than 0 or greater than 65535.
"Invalid port. Exiting..." occurs when the port assigned to chromedriver is less than 0 or greater than 65535.
解决方案
- 通过 CLI 执行
netstat
命令以查看您是否已达到可能打开的连接的限制,或者检查给定端口上是否正在运行其他应用程序. - 检查防火墙设置,很有可能是防火墙配置引起了问题.
- 将 ChromeDriver 升级到当前的 ChromeDriver v2.38 级别.
- 保持 Chrome 版本处于 Chrome v66.x 级别. (根据ChromeDriver v2.38发行说明) 通过 IDE
- 清理您的项目工作区和重建您的项目,并且仅具有必需的依赖项.
- 使用 CCleaner 工具清除之前和之后的所有操作系统杂项在执行 test Suite 之后.
- 如果您的基本 Web客户端版本太旧,请通过来卸载. Revo Uninstaller 并安装最新版本的 Web客户端 GA和发行版.
- 进行系统重启释放端口.
- 执行您的
@Test
. - Execute
netstat
command through CLI to see if you have reached limit of possible open connections or check if there is another application running on the given port. - Check your firewall settings, there is a good chance that firewall configuration may be causing the issue.
- Upgrade ChromeDriver to current ChromeDriver v2.38 level.
- Keep Chrome version at Chrome v66.x levels. (as per ChromeDriver v2.38 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
- If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
- Take a System Reboot to free up the ports.
- Execute your
@Test
. -
代码块:
Code Block:
Solution
注意:步骤1、2、7和8对于调试/解决您当前遇到的问题至关重要.
Note : Steps 1, 2, 7 and 8 are vital to debug/solve the issue you are currently facing.
As an alternative you can force the WebDriver variant i.e. ChromeDriver to start on a specific port e.g. 65530
as follows:
System.setProperty("webdriver.chrome.driver","C:\\WebDrivers\\chromedriver.exe");
WebDriver driver= new ChromeDriver(new ChromeDriverService.Builder().usingPort(65530).build());
driver.get("https://www.google.com/");
控制台输出:
Console Output:
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 65530
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Jul 20, 2020 7:36:17 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
您可以在以下位置找到几个相关的详细讨论:
You can find a couple of relevant detailed discussions in:
- 端口无效.在线程主" org.openqa.selenium.WebDriverException中退出..Exception:驱动程序服务器进程过早地死于ChromeDriver Selenium
- org .openqa.selenium.os.OsProcess checkForError和org.apache.commons.exec.ExecuteException:Selenium ChromeDriver错误退出进程
- " OsProcess checkForError:CreateProcess错误= 193,%1不是有效的Win32应用程序",通过Java和Selenium启动Internet Explorer时
- Invalid port. Exiting..Exception in thread "main" org.openqa.selenium.WebDriverException: Driver server process died prematurely ChromeDriver Selenium
- org.openqa.selenium.os.OsProcess checkForError and org.apache.commons.exec.ExecuteException: Process exited with an error with Selenium ChromeDriver
- "OsProcess checkForError : CreateProcess error=193, %1 is not a valid Win32 application" while starting Internet Explorer through Java and Selenium
这篇关于无效的端口.正在退出... org.openqa.selenium.os.OsProcess checkForError使用硒启动chrome时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!