简体   繁体   中英

Assert for special characters in python Appium

How to assert special characters in python using Appium. I have tried to change the text encoding but it does not help, by default i am using UTF-8 text encoding (Eclipse)

I would like to assert the below mentioned text:

Text: Köp avslutat

My xpath for the text is:

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

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

and it worked with: u*ko\̈p avslutat"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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