Pergunta

I have a page that contains a form with some input elements, including a textarea. Those input fields are populated with some values. Think of this whole page as an edit page for some entity. Textarea contains an XML string that shows properly within normal browser (eg. firefox and chrome) and looks like following:

<front>

  <!-- top row -->
    <cell>
      <page>8</page>
    </cell>

</front>

But when i run the test case with goutte mink driver the page is loaded and the value of textarea is encoded with special characters, like so:

&lt;front&gt;&#13;
&#13;
    &lt;!-- top row --&gt;&#13;
        &lt;cell&gt;&#13;
            &lt;page&gt;8&lt;/page&gt;&#13;
        &lt;/cell&gt;&#13;
&#13;
&lt;/front&gt;&#13;

And when i press submit button that mess is sent to the server and saved instead of initial correct xml. Note that i do not touch it at all. I can just load the page and press submit button and it's all screwed. This happens only with goutte, but not with, say, selenium2.

So the question is: how can i force goutte interpret those html entities automatically and send them as correct data, not that encoded mess?

Foi útil?

Solução

there's no solution for that. It seems as normal behavior of Goutte/Guzzle. As a workaround we ended up with following solution: in case Goutte driver is used we check page contents for all <textarea> elements, and if any found then for each we get their contents and plainly reinsert as follows:

$elements = $this->pageContent->findAll('xpath', '//textarea');
foreach ($elements as $element) {
    $element->setValue($element->getText());
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top