Kei*_*vis 5 windows selenium phpunit google-chrome selenium-chromedriver
我正在使用 PHPUnit 运行所有测试。创建了一个包装器,用于启动 Apache 实例,然后启动 Selenium 独立服务器,然后在http://localhost:4444/wd/hub创建 Chrome Remote Webdriver 实例。这个过程在我们的开发机器上 100% 的时间有效,在测试服务器上 90% 的时间有效,但有时测试会失败,如下所示:
[exec] 1) Intranet\Pages\FinancialReportsSeleniumTest::test_changeMonthYear
[exec] Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--window-size=1400,900","--no-sandbox","--headless"]},"goog:chromeOptions":{"args":["--window-size=1400,900","--no-sandbox","--headless"]}}}
[exec]
[exec] Failed to connect to localhost port 4444: Connection refused
[exec]
[exec] C:\Jenkins\jobs\Intranet-Master\workspace\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:292
[exec] C:\Jenkins\jobs\Intranet-Master\workspace\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:126
[exec] C:\Jenkins\jobs\Intranet-Master\workspace\phpunit\library\Intranet\Selenium.php:364
[exec] C:\Jenkins\jobs\Intranet-Master\workspace\phpunit\library\Intranet\Selenium.php:51
[exec] C:\Jenkins\jobs\Intranet-Master\workspace\phpunit\library\Intranet\SeleniumTestCase.php:9
Run Code Online (Sandbox Code Playgroud)
如果我们重新运行测试,下次就可以正常工作。
开发机器:
试验机
日志文件显示服务器已启动:
10:41:27.392 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
10:41:27.392 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
10:41:28.562 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
Run Code Online (Sandbox Code Playgroud)
更新 #1:我们现在将 Selenium 独立服务器作为服务启动,但仍然以相同的频率失败(每 5-10 次测试运行一次)。
更新#2:我们现在在运行任何测试之前启动 Apache 实例和远程 Web 驱动程序作为 PHPUnit 引导文件的一部分。我们现在还使用 fsockopen() 测试 Web 驱动程序是否正在运行(首先,在尝试启动它之前)。故障率已降至5%以下,但仍时有发生。奇怪的是,在我们添加 fsockopen() 调用之后,实际上似乎出现了改进 - 也许存在某种计时问题?
这个错误信息...
\n\n [exec] Facebook\\WebDriver\\Exception\\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--window-size=1400,900","--no-sandbox","--headless"]},"goog:chromeOptions":{"args":["--window-size=1400,900","--no-sandbox","--headless"]}}}\n
Run Code Online (Sandbox Code Playgroud)\n\n...意味着初始化Chrome 浏览器会话时引发了Curl错误。
\n\n您的主要问题似乎是将desiredCapability platform
设置为ANY
。
根据处理功能 - WebDriver W3C Living Document的platformName部分,以下平台名称是常用的且具有易于理解的语义,并且在匹配功能时,可以通过将它们视为知名操作系统的有效同义词来实现最大的互操作性:
\n\nKey System\n--- ------\n"linux" Any server or desktop system based upon the Linux kernel.\n"mac" Any version of Apple\xe2\x80\x99s macOS.\n"windows" Any version of Microsoft Windows, including desktop and mobile versions.\n
Run Code Online (Sandbox Code Playgroud)\n\n注意:此列表并不详尽。
\n\n从新会话返回功能时,返回更具体的 platformName 是有效的,从而允许用户正确识别 WebDriver 实现正在运行的操作系统。
\n\n因此,与其"platform":"ANY"
在期望的能力对象中传递,"platform":"windows"
不如采用更具体的方法。
归档时间: |
|
查看次数: |
4965 次 |
最近记录: |