Codeception PhpBrowser grabAttributeFrom throws Exception DOMDocument::loadXML()

末鹿安然 提交于 2019-12-12 05:17:51

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!