首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用params:{"desiredCapabilities":{"browserName":"chrome",“platform”:带Selenium和PHPUnit的http到/session引发的Curl错误:“ANY”

使用params:{"desiredCapabilities":{"browserName":"chrome",“platform”:带Selenium和PHPUnit的http到/session引发的Curl错误:“ANY”
EN

Stack Overflow用户
提问于 2019-02-18 17:38:25
回答 1查看 4.1K关注 0票数 5

我正在使用PHPUnit运行所有测试。创建一个包装器,启动Apache实例,然后启动Selenium独立服务器,然后在http://localhost:4444/wd/hub上创建Chrome实例。此过程在我们的dev机器上工作时间为100%,在测试服务器上为90%,但有时测试失败:

代码语言:javascript
复制
 [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

如果我们重新运行测试,下次就能正常工作了。

发展机器:

  • Windows 10 Pro (1809年) (64位)
  • Apache 2.4.38 (32位)
  • PHP 7.2.15 (32位)
  • Java 1.8.0_192 (64位)
  • 硒3.141.59
  • 硒铬驱动器73.0.3683.20

试验机

  • Windows 2008 R2 x64 (64位)
  • Apache 2.4.38 (32位)
  • PHP 7.2.15 (32位)
  • Jenkins 2.1.64
  • Java 1.8.0_192 (64位)
  • 硒3.141.59
  • 硒铬驱动器73.0.3683.20

日志文件显示服务器已启动:

代码语言:javascript
复制
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()调用之后,实际上似乎出现了改进--可能存在某种时间问题?

EN

回答 1

Stack Overflow用户

发布于 2019-02-18 19:50:14

这个错误信息..。

代码语言:javascript
复制
 [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活动文档,以下平台名称在语义上很常见,在匹配功能时,可以通过将它们作为著名操作系统的有效同义词来实现最大的互操作性:

代码语言:javascript
复制
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"将是更理想的方法。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54752626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档