为什么在新浪新闻文本框中输入鸦片打字中文会出现乱码

时间:2018-10-09 05:46:23

标签: python python-3.x appium-desktop

Appium v​​1.9.0 Windows10的 python3.6

我正在使用appium测试新浪新闻应用程序。 enter image description here

中文乱码。

我的代码

#-*-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()

enter image description here

为什么在新浪新闻文本框中输入鸦片打中文?

0 个答案:

没有答案