1

Appium v​​1.9.0 windows10 python3.6

我正在使用 appium 来测试新浪新闻应用。 在此处输入图像描述

是中文乱码。

我的代码

#-*-coding:utf-8-*-
#import package
from selenium.webdriver.support.ui import WebDriverWait
from appium import webdriver


#create desired_caps
desired_caps = {}
desired_caps['platformName'] = 'Android'
#devicename
desired_caps['deviceName'] = 'TGIRPJOBFUZ9IJSW'
#platformVersion
desired_caps['platformVersion'] = '6.0'
#appPackage name
desired_caps['appPackage'] = 'com.sina.news'
desired_caps['appActivity'] = 'com.sina.news.ui.MainActivity'
desired_caps['noReset'] = True
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True

#start up appium
driver = webdriver.Remote('http://192.168.54.56:4723/wd/hub', desired_caps)

#check xpath
if WebDriverWait(driver,20).until(lambda x:x.find_element_by_xpath("//android.widget.TextView[@resource-id='com.sina.news:id/avl']")):
    #click
    driver.find_element_by_xpath("//android.widget.TextView[@resource-id='com.sina.news:id/avl']").click()
    #send keys
    driver.find_element_by_xpath("//android.widget.EditText[@resource-id='com.sina.news:id/ajg']").send_keys('汉能')
    while driver.find_element_by_xpath("//android.widget.EditText[@resource-id='com.sina.news:id/ajg']").text != "汉能":
        driver.find_element_by_xpath("//android.widget.EditText[@resource-id='com.sina.news:id/ajg']").send_keys('汉能')
    driver.find_element_by_xpath("//android.widget.ListView[@resource-id='com.sina.news:id/avn']/android.widget.LinearLayout[1]/android.widget.RelativeLayout[1]").click()

在此处输入图像描述

为什么appium在新浪新闻文本框中输入中文出现乱码?

4

0 回答 0