我正在使用PHPUnit运行所有测试。创建一个包装器,启动Apache实例,然后启动Selenium独立服务器,然后在http://localhost:4444/wd/hub上创建Chrome实例。此过程在我们的dev机器上工作时间为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如果我们重新运行测试,下次就能正常工作了。
发展机器:
试验机
日志文件显示服务器已启动:
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更新1:我们现在启动Selenium独立服务器作为一个服务,仍然失败的频率大致相同(每5-10次测试运行一次)。
更新2:在运行任何测试之前,我们在PHPUnit引导文件中启动Apache实例和远程web驱动程序。我们现在还使用fsockopen()测试web驱动程序是否正在运行(首先,在尝试启动它之前)。故障率下降到不到5%,但仍然时有发生。奇怪的是,在我们添加fsockopen()调用之后,实际上似乎出现了改进--可能存在某种时间问题?
发布于 2019-02-18 19:50:14
这个错误信息..。
[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"]}}}...implies :初始化Chrome浏览器会话时引发Curl错误。
您的主要问题似乎是将ANY.设置为desiredCapability platform。
根据platformName节中的处理能力- WebDriver W3C活动文档,以下平台名称在语义上很常见,在匹配功能时,可以通过将它们作为著名操作系统的有效同义词来实现最大的互操作性:
Key System
--- ------
"linux" Any server or desktop system based upon the Linux kernel.
"mac" Any version of Apple’s macOS.
"windows" Any version of Microsoft Windows, including desktop and mobile versions.注意事项:此列表并非详尽无遗。
当从New返回功能时,返回一个更具体的platformName是有效的,允许用户正确识别运行WebDriver实现的操作系统。
因此,与在"platform":"ANY"对象中传递desiredCapabilities不同,更具体的"platform":"windows"将是更理想的方法。
https://stackoverflow.com/questions/54752626
复制相似问题