xpath assertion failure with dynamic xpath

谁都会走 提交于 2019-12-08 07:51:31

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/31999509/xpath-assertion-failure-with-dynamic-xpath

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