【发布时间】:2016-11-28 17:06:25
【问题描述】:
我正在使用 Codeception 2.2.6 来测试 Laravel 应用程序。我有一个简单的测试,它打开一个带有表单的页面,填写一些字段,然后单击一个按钮。当我运行测试时,它工作正常,直到单击步骤,然后它失败并出现以下错误:
[ErrorException] Undefined property: DOMDocument::$tagName
堆栈跟踪显示错误是由Codeception\Lib\InnerBrowser.php 中的clickButton 方法引发的:
/**
* Clicks the link or submits the form when the button is clicked
* @param \DOMNode $node
* @return boolean clicked something
*/
private function clickButton(\DOMNode $node)
{
$formParams = [];
$buttonName = (string)$node->getAttribute('name');
$buttonValue = $node->getAttribute('value');
if ($buttonName !== '' && $buttonValue !== null) {
$formParams = [$buttonName => $buttonValue];
}
while ($node->parentNode !== null) {
$node = $node->parentNode;
if ($node->tagName === 'a') {
$this->openHrefFromDomNode($node);
return true;
} elseif ($node->tagName === 'form') {
$this->proceedSubmitForm(
new Crawler($node),
$formParams
);
return true;
}
}
return false;
}
我还有其他类似的测试,使用点击不同的页面没有问题。有人可以帮我找出导致错误的原因
【问题讨论】: