动态xpath的xpath断言失败 [英] xpath assertion failure with dynamic xpath

查看:207
本文介绍了动态xpath的xpath断言失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这非常类似于:将php变量添加到Xpath 但略有不同...

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

我想做的是这样:

$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!.'

任何想法为何将$ elementtext设置为"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.

推荐答案

我发现了问题.

这是因为postToPage()将其内容输入到另一个span元素,因此,我的waitUntil()指的是继续,而不是新创建的span.我的断言也仍然在考虑与postToPage()有关.

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.

这篇关于动态xpath的xpath断言失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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