Appium xpath转义撇号 [英] Appium xpath escaping apostrophes

查看:98
本文介绍了Appium xpath转义撇号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的appium脚本中包含以下代码:

I have the code below in my appium script:

    public boolean isErrorDisplayedUnrecognisedLoginCredentials() {
        return appDriver.isElementExist(By.xpath("//UIAStaticText[@name='We don't recognize this user ID or password']"));
    }

该测试正在挂起,因为它将不要"中的撇号作为最终的撇号来关闭@name值.我尝试使用\',\','

The test is hanging since it treats the apostrophe in "don't" as a final apostrophe to close off the @name value. I have tried escaping the apostrophe in "don't" by using \', \', '

但是,这些都不起作用,测试一直失败.有人知道如何解决这个问题吗?

However, none of these are working and the tests keep failing. Anyone know how to get round this?

推荐答案

AFAIK,您不能在xpath中转义引号,但可以在Java中转义引号.因此,请尝试对xpath文字字符串定界符使用转义的双引号,例如:

AFAIK, you can't escape quotes in xpath, but you can escape quotes in Java. So try to use escaped double quotes for the xpath literal string delimiter, for example :

By.xpath("//UIAStaticText[@name=\"We don't recognize this user ID or password\"]")

这篇关于Appium xpath转义撇号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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