Appium v1.9.0 Windows10的 python3.6
中文乱码。
我的代码
#-*-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()
为什么在新浪新闻文本框中输入鸦片打中文?