问题
I updated my tests from Codeception 2.0.9 to 2.1.5.
Everything works fine except the PhpBrowser::grabAttributeFrom()
method. I'll get a PHPUnit exception like this:
[PHPUnit_Framework_Exception] DOMDocument::loadXML(): Entity 'nbsp' not defined in Entity, line: 3
or
[PHPUnit_Framework_Exception] DOMDocument::loadXML(): Opening and ending tag mismatch: img line 141 and a in Entity, line: 142
It seems, that the grabAttributeFrom
is very strict with HTML-DOM parsing. I googled the message and found, that the DOMDocument::loadHtml()
is a bit less strict and would work.
http://php.net/manual/en/domdocument.loadhtml.php
How can I fix this grabAttributeFrom? I need the content of a href/src
attribute of a HTML file.
回答1:
The hint of @Naktibalda guides myself to the resolution. It's a conflict of the modules REST and PhpBrowser. Both modules have implemented the function grabAttributeFrom
. To get the right one, you have to change the order in the configuration, to get the one of PhpBrowser:
modules:
enabled:
- REST:
depends: PhpBrowser
url: 'http://www.domain.com'
- PhpBrowser:
url: 'http://www.domain.com'
This works for me, because PhpBrowser now overrules the method in the builded AcceptanceTester.php.
来源:https://stackoverflow.com/questions/35154931/codeception-phpbrowser-grabattributefrom-throws-exception-domdocumentloadxml