1

This is very similar to: adding php variable into Xpath But slightly different...

What I'm trying to do is this:

$status = "Test!";

//ajax request to update the page

$this->postToPage($status);

//This is the part that is failing..

$this->waitUntil(function ()
{
    if ($this->byXPath("//span[contains(text(),'{$status}')]"))
    {
        return true;
    }
    return null;
}, 20000);

$elementtext = $this->byXpath("//span[contains(text(),'{$status}')]")->text();

$this->assertEquals($status, $elementtext);

Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'Test!' +'Test!.'

Any idea why $elementtext is being set to "Test!." with the dot on the end? I've come to a stalemate here and have no idea why on earth it is appending the dot.

Community
  • 1
  • 1
simon
  • 854
  • 1
  • 9
  • 23
  • Please show the HTML representation of the `span` element you are locating. – alecxe Aug 13 '15 at 22:34
  • It has no tags other than – simon Aug 13 '15 at 23:03
  • Essentially postToPage($status) adds the element to the page. What I'm trying to use assertEquals() for is to assert that the contents of match up with that of $status – simon Aug 13 '15 at 23:05
  • to be more explicit: $status or in this case, my span is exactly this on my page: Test! yet when calling the method described in $elementtext, I'm getting returned "Test!." – simon Aug 13 '15 at 23:18
  • Interesting enough, if I echo $elementtext, I get "Test!.", but if I sleep for a few seconds and then echo, I get "Test!" – simon Aug 14 '15 at 00:18

1 Answers1

0

I found my issue.

It's because postToPage() is inputting its contents into another span element, and therefore, my waitUntil() referred to that to continue, rather than the newly created span. my assert also was still grabbing the in regards to postToPage() as well.

simon
  • 854
  • 1
  • 9
  • 23