简体   繁体   English

断言python Appium中的特殊字符

[英]Assert for special characters in python Appium

How to assert special characters in python using Appium. 如何使用Appium在python中声明特殊字符。 I have tried to change the text encoding but it does not help, by default i am using UTF-8 text encoding (Eclipse) 我试图更改文本编码,但无济于事,默认情况下,我使用的是UTF-8文本编码(Eclipse)

I would like to assert the below mentioned text: 我要声明以下提到的文本:

Text: Köp avslutat 文字:Köpavslutat

My xpath for the text is: 我的文字的xpath是:

Xpath: //UIAApplication[1]/UIAWindow[4]/UIAStaticText[1] Xpath:// UIAApplication [1] / UIAWindow [4] / UIAStaticText [1]

My code is here: 我的代码在这里:

try:
    assert_var = self.driver.find_element_by_xpath("//UIAApplication[1]/UIAWindow[4]/UIAStaticText[1]")

    return assert_var.text == "Köp avslutat"
    WebdriverWait(self.driver, 10).until(EC.presence_of_element_located(xpath of element))

except:
    raise NoSuchElementException("Unable to locate assert text")

I have figured it out, there are Unicode character Encoding and Python uses different encoding 我已经弄清楚了,有Unicode字符编码和Python使用不同的编码

www.fileformat.info/info/unicode/char/0308/index.htm www.fileformat.info/info/unicode/char/0308/index.htm

and it worked with: u*ko\̈p avslutat" 并与以下产品一起使用:u * ko \\ u0308p avslutat“

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM