PhpBrowser也可以执行同样的操作,但一旦我在acceptance.suite.yml中设置WebDriver,它就会引发以下错误:
[PHPUnitFrameworkException] Invalid argument supplied for foreach() at vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:240
我遵循了使用Selenium设置WebDriver的文档。这是我的acceptance.suite.yml的样子:
actor: AcceptanceTester
modules:
enabled:
- WebDriver:
url: '{website url here}'
browser: chrome
- HelperAcceptance
step_decorators: ~
这是我的验收测试文件:
<?php
class FirstAcceptanceCest
{
public function _before(AcceptanceTester $I)
{
}
public function seeLoginInFrontPage(AcceptanceTester $I)
{
$I->amOnPage('/');
$I->see('Login');
}
}
如有任何帮助,我们将不胜感激。
php网络驱动程序库中的错误处理再次出现问题。
https://github.com/php-webdriver/php-webdriver/blob/1.13.1/lib/Remote/RemoteWebDriver.php#L228-L245
$raw_elements = $this->execute(
DriverCommand::FIND_ELEMENTS,
JsonWireCompat::getUsing($by, $this->isW3cCompliant)
);
if ($raw_elements === null) {
throw new UnknownErrorException('Unexpected server response to findElements command');
}
$elements = [];
foreach ($raw_elements as $raw_element) {
$elements[] = $this->newElement(JsonWireCompat::getElement($raw_element));
}
我的调试建议是添加
if (!is_array($raw_elements) && !is_object($raw_elements)) {
var_dump($raw_elements); die;
}
在CCD_ 1之前,查看输出是否有助于理解根本原因。