org.openqa.selenium.WebDriverException:等待驱动程序服务器从Selenium和Java启动时超时

艾玛萨尔

我已经尝试了Stackoverflow主题中讲述的所有内容。我有通过jenkins在远程从站上运行的Java硒测试。荒谬的是第一个测试始终运行和浏览器打开时,所有其他的测试给我“超时等待司机服务器开始”。

public WebDriver startChrome() {
            
    System.setProperty("java.net.preferIPv4Stack", "true");
    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    ChromeOptions chromeOptions = new ChromeOptions();
    Map<String, Object> prefs = new HashMap<String, Object>();
    prefs.put("credentials_enable_service", false);
    prefs.put("profile.password_manager_enabled", false);
    chromeOptions.addArguments("--no-sandbox"); 
    chromeOptions.addArguments("--disable-dev-shm-usage"); 
    chromeOptions.addArguments("--aggressive-cache-discard"); 
    chromeOptions.addArguments("--disable-cache"); 
    chromeOptions.addArguments("--disable-application-cache"); 
    chromeOptions.addArguments("--disable-offline-load-stale-cache"); 
    chromeOptions.addArguments("--disk-cache-size=0");
    chromeOptions.addArguments("--dns-prefetch-disable"); 
    chromeOptions.addArguments("--no-proxy-server"); 
    chromeOptions.addArguments("--log-level=3"); 
    chromeOptions.addArguments("--silent"); 
    chromeOptions.addArguments("--disable-browser-side-navigation"); 
    chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL); 
    chromeOptions.addArguments("-disable-cache");
    chromeOptions.addArguments("-disable-extensions");
    chromeOptions.addArguments("--incognito");
    chromeOptions.addArguments("start-maximized");
    //chromeOptions.setExperimentalOption("useAutomationExtension", false);
    ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
    port = chromeDriverService.getUrl().getPort();
    return new ChromeDriver(chromeDriverService, chromeOptions);
}

错误:

Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'
Driver info: driver.version: unknown
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:231)
    at org.openqa.selenium.remote.service.DriverService.lambda$start$0(DriverService.java:193)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:35592/status] to be available after 20000 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:90)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:227)
    ... 7 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(FutureTask.java:205)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:88)
    ... 8 more

到目前为止,我尝试过的所有解决方案:

  • 更新Java 1_8_271
  • 更新硒4
  • 更新ChromeDriver 87
  • 使用rawcap检查本地主机流量
  • 在/ etc / hosts中检查localhost dns definiton
  • 更新Chrome 87
  • 设置代理
  • 检查端口可用性
  • 检查驱动程序路径
  • 在创建之前终止所有chrome和驱动程序任务(仅适用于解决方案,但不适用于并行测试)
  • 检查localhost网址和端口是否可以通过Chrome访问-> http 200

当我尝试通过代码驱动程序中的java urlconnection创建功能捕获块来访问url和端口时,它为我重置了连接,但在chrome中为200。

所有帮助将不胜感激。

最好的祝福

DebanjanB

此错误消息...

Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start. 
Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5' 
System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271' 
Driver info: driver.version: unknown

...暗示ChromeDriver无法启动/产生新的浏览上下文,Chrome浏览器会话。

有关您的用例的更多信息,将有助于我们以更好的方式分析错误。但是,从一开始,您只能使用一个参数,start-maximized然后删除所有其他参数即可开始使用。因此,您的有效代码块将是:

public WebDriver startChrome() {

    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.addArguments("start-maximized");
    ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();
    return new ChromeDriver(chromeDriverService, chromeOptions);
}

附加注意事项

确保这件事:

  • JDK已升级到当前级别的JDK 8u271
  • Selenium已升级到当前发行的3.141.59版本
  • ChromeDriver已更新为当前的ChromeDriver v87.0级别。
  • Chrome已更新为当前的Chrome版本87.0(根据ChromeDriver v87.0发行说明)。
  • 如果您的基本Web客户端版本太旧,则将其卸载并安装最新的GA和Web客户端的发行版本
  • 进行系统重启
  • @Test非root用户身份执行
  • 始终driver.quit()tearDown(){}方法调用优雅地关闭和销毁WebDriverWeb Client实例。

参考文献

您可以在以下位置找到几个相关的详细讨论:

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Selenium Chrome浏览器org.openqa.selenium.WebDriverException:等待驱动程序服务器启动时超时

org.openqa.selenium.NoSuchElementException

无效的端口。线程“主”中退出Exiting..Exception org.openqa.selenium.WebDriverException:驱动程序服务器进程过早地终止了ChromeDriver Selenium

org.openqa.selenium.WebDriverException:超时等待司机服务器开始。生成信息:版本:“未知”,修订版:“未知”

获取异常 org.openqa.selenium.SessionNotCreatedException

引起:org.openqa.selenium.InvalidSelectorException:

Firefox-org.openqa.selenium.interactions.MoveTargetOutOfBoundsException

org.openqa.selenium.WebDriverException:java.io.IOException异常

org.openqa.selenium.remote.UnreachableBrowserException: - 错误 selenium Java TestNG

Selenium Actions.movetoElement-org.openqa.selenium.UnsupportedCommandException

Selenium 错误 - org.openqa.selenium.SessionNotCreatedException 会话创建异常

是什么导致JBrowserDriver WebDriverException:org / openqa / selenium / security / Credentials

启动应用程序时显示的异常 - org.openqa.selenium.WebDriverException:

org.openqa.selenium.WebDriverException:浏览器无法启动,在fluentlium中测试

OpenQA.Selenium.WebDriverException:'无法在http:// localhost:20548 /上启动驱动程序服务

java.lang.ClassCastException:类org.openqa.selenium.By $ ByXPath无法转换为类org.openqa.selenium.WebElement

java.lang.ClassCastException: org.openqa.selenium.By$ById 不能转换为 org.openqa.selenium.WebElement

OpenQA.Selenium.WebDriverException

org.openqa.selenium.InvalidArgumentException:使用DesiredCapabilities的功能无效

org.openqa.selenium.UnhandledAlertException:意外警报打开

无法解析类参考org / openqa / selenium / WebDriver

org.openqa.selenium.NoSuchElementException:无法找到元素错误

仅针对Chrome获取org.openqa.selenium.InvalidSelectorException

线程“主” org.openqa.selenium.InvalidElementStateException中的异常:

org.openqa.selenium.NoAlertPresentException:没有警报打开

org.openqa.selenium.ElementNotInteractableException:无法单击元素

无法找到元素:org.openqa.selenium.NoSuchElementException

错误:无法解析类引用org / openqa / selenium / WebDriver

线程“主” org.openqa.selenium.WebDriverException中的异常:geckodriver升级后,等待Firefox等待45秒超时