所以,我忠实地遵循了Codeception Quick Start instructions。我使用PhpBrowser运行第一个示例测试...
# Codeception Test Suite Configuration
#
# [further comments omitted]
#
actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: 'http://office.localhost/'
browser: 'firefox'
- \Helper\Acceptance测试:
<?php
class FirstCest
{
public function frontpageWorks(AcceptanceTester $I)
{
$I->amOnPage('/');
$I->see('We hope you enjoy it');
}
}一切都很好。
然后,我将配置更改为:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://office.localhost/'
browser: 'firefox'
- \Helper\Acceptance根据说明,我已经安装了Selenium并启动并运行,然后我们就可以开始了……
1) FirstCest: Frontpage works
Test tests/acceptance/FirstCest.php:frontpageWorks
[PHPUnit\Framework\Exception] Undefined index: ELEMENT
Scenario Steps:
2. $I->see("InterpretersOffice") at tests/acceptance/FirstCest.php:22
1. $I->amOnPage("/") at tests/acceptance/FirstCest.php:21
#1 /opt/www/court-interpreters-office/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:198
#2 Codeception\Module\WebDriver->see
#3 /opt/www/court-interpreters-office/tests/_support/_generated/AcceptanceTesterActions.php:363
#4 /opt/www/court-interpreters-office/tests/acceptance/FirstCest.php:22
#5 FirstCest->frontpageWorksSelenium驱动着火狐,页面被加载,$I想要see()的内容就在那里,所以这不是问题所在。我已经研究了一下源码,但还没有弄清楚。我试着把$I->see()改成$I->seeInSource(),我发现这样做是可行的。
有什么想法吗?
发布于 2018-01-17 04:29:21
问题很明显是Facebook的php-webdriver与当前的Firefox不兼容。
These threads更详细地讨论了这个问题,php-webdriver issue #469跟踪添加了完整的W3C WebDriver支持(这将修复不兼容性)。
一种解决方法是在启动Selenium时添加-enablePassthrough false参数。例如:
java -Dwebdriver.gecko.driver=./geckodriver -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false不幸的是,Selenium removed support for pass through mode in 3.9,所以你必须使用一个旧版本。
另一种解决方法是切换到Chrome。
发布于 2018-09-12 20:23:57
在我的例子中,唯一的解决方案是:
Install chromedriver in a path that is in $PATH (/usr/bin or /bin)并在测试类中使用:
$capabilities = DesiredCapabilities::chrome()它以执行Selenium标准的方式工作:
java -jar selenium-server-standalone-3.14.0.jar发布于 2019-08-29 22:22:20
在我的Ubuntu版本上有不同的情况。18.x:
php composer.phar require facebook/webdriver重新构建它。https://stackoverflow.com/questions/46913377
复制相似问题