MDL-37958 behat: Nasty strings in HTML

Nasty strings includes html entities and
non-breaking spaces followed by spaces which makes
very hard to find these strings in the DOM html,
this patch keeps the non-breaking spaces and all
the nasty characters, but leaves them isolated from
other regular spaces. It swaps the strings to HTML before
finding elements in the HTML that matches that contents.
This commit is contained in:
David Monllao
2013-03-06 13:34:09 +08:00
parent c629c91feb
commit 0a7f6a02eb
2 changed files with 16 additions and 10 deletions
+6
View File
@@ -102,6 +102,12 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
if ($selector == 'named') {
$exceptiontype = $locator[0];
$exceptionlocator = $locator[1];
// If we are in a @javascript session all contents would be displayed as HTML characters.
if (get_class($this->getSession()->getDriver()) === 'Behat\Mink\Driver\Selenium2Driver') {
$locator[1] = html_entity_decode($locator[1], ENT_NOQUOTES);
}
} else {
$exceptiontype = $selector;
$exceptionlocator = $locator;
+10 -10
View File
@@ -48,16 +48,16 @@ class nasty_strings {
* @var array
*/
protected static $strings = array(
'< > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ @@TEST@@ \\\" \\ , ; : .  日本語 ­ % %% ',
'&amp; \' \\" \ \'$@NULL@$ < > & &lt; &gt; @@TEST@@ \\\" \\ , ; : .  日本語 ­ % %% ',
'< > & &lt; &gt; &amp; \' \\" \ \\\" \\ , ; : .  \'$@NULL@$ @@TEST@@ 日本語 ­ % %% ',
'< > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ 日本語 ­ % %%@@TEST@@ \\\" \\ , ; : .  ',
'< > & &lt; &gt; \\\" \\ , ; : .  日本語&amp; \' \\" \ \'$@NULL@$ @@TEST@@ ­ % %% ',
'\' \\" \ \'$@NULL@$ @@TEST@@ < > & &lt; &gt; &amp; \\\" \\ , ; : .  日本語 ­ % %% ',
'\\\" \\ , ; : .  日本語 ­ % < > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ @@TEST@@ %% ',
'< > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ 日本語 ­ % %% @@TEST@@ \\\" \\ , ; : .  ',
'.  日本語&amp; \' \\"< > & &lt; &gt; \\\" \\ , ; : \ \'$@NULL@$ @@TEST@@ ­ % %% ',
'&amp; \' \\" \ < > & &lt; &gt; \\\" \\ , ; : .  日本語\'$@NULL@$ @@TEST@@ ­ % %% ',
'< > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ @@TEST@@ \\\" \\ , ; : . 日本語­% %%',
'&amp; \' \\" \ \'$@NULL@$ < > & &lt; &gt; @@TEST@@ \\\" \\ , ; : . 日本語­% %%',
'< > & &lt; &gt; &amp; \' \\" \ \\\" \\ , ; : . \'$@NULL@$ @@TEST@@ 日本語­% %%',
'< > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ 日本語­% %%@@TEST@@ \. \\" \\ , ; :',
'< > & &lt; &gt; \\\" \\ , ; : . 日本語&amp; \' \\" \ \'$@NULL@$ @@TEST@@­% %%',
'\' \\" \ \'$@NULL@$ @@TEST@@ < > & &lt; &gt; &amp; \\\" \\ , ; : . 日本語­% %%',
'\\\" \\ , ; : . 日本語­% < > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ @@TEST@@ %%',
'< > & &lt; &gt; &amp; \' \\" \ \'$@NULL@$ 日本語­% %% @@TEST@@ \\\" \\ . , ; :',
'. 日本語&amp; \' \\"< > & &lt; &gt; \\\" \\ , ; : \ \'$@NULL@$ @@TEST@@­% %%',
'&amp; \' \\" \ < > & &lt; &gt; \\\" \\ , ; : . 日本語\'$@NULL@$ @@TEST@@­% %%',
);
/**