编码接收PhpBrowsergrabAttributeFrom引发异常DOMDocument :: loadXML() [英] Codeception PhpBrowser grabAttributeFrom throws Exception DOMDocument::loadXML()

查看:145
本文介绍了编码接收PhpBrowsergrabAttributeFrom引发异常DOMDocument :: loadXML()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的测试从Codeception 2.0.9更新到了2.1.5。

I updated my tests from Codeception 2.0.9 to 2.1.5.

除了 PhpBrowser :: grabAttributeFrom()<之外,其他一切工作正常/ code>方法。我将得到一个如下所示的PHPUnit异常:

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

[PHPUnit_Framework_Exception] DOMDocument::loadXML(): Opening and ending tag mismatch: img line 141 and a in Entity, line: 142

看来, grabAttributeFrom 对于HTML-DOM解析非常严格。我在邮件中搜索,发现 DOMDocument :: loadHtml()不太严格,可以使用。

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

我该如何解决该grapAttributeFrom?我需要HTML文件的 href / src 属性的内容。

How can I fix this grabAttributeFrom? I need the content of a href/src attribute of a HTML file.

推荐答案

@Naktibalda的提示可指导我自己解决问题。 REST和PhpBrowser模块之间存在冲突。这两个模块都实现了功能 grabAttributeFrom 。要获得正确的版本,必须更改配置顺序,以获取PhpBrowser的版本:

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'

这对我有用,因为PhpBrowser现在否决了该方法在构建的AcceptanceTester.php中。

This works for me, because PhpBrowser now overrules the method in the builded AcceptanceTester.php.

这篇关于编码接收PhpBrowsergrabAttributeFrom引发异常DOMDocument :: loadXML()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆