请教一个中文输入问题,我使用 python+appium+android 模拟器:
unicodeKeyboard:True
resetKeyboard:True
appium android input manager for unicode 通过手动安装
# -*- coding: UTF-8 -*-
platform={}
platform['platformName']='Android'
platform['platformVersion']='4.3'
platform['deviceName']='test'
platform['unicodekeyboard']=True
platform['resetkeyboard']=True
# -*- coding:UTF-8 -*-
'''
test send message
'''
# import sys
# reload(sys)
# sys.setdefaultencoding('UTF-8')
import unittest,HTMLTestRunner
from platform_info import platform
from appium import webdriver
from time import sleep
class SMS(unittest.TestCase):
"""docstring for SMS"""
def setUp(self):
platform["appPackage"]="com.android.mms"
platform["appActivity"]=".ui.ConversationList"
self.driver=webdriver.Remote("http://localhost:4723/wd/hub",platform)
def tearDown(self):
self.driver.quit()
def test_send_message(self):
self.driver.find_element_by_xpath(" \
//android.widget.TextView[contains(@content-desc,'新信息')]").click()
input_number = self.driver.find_element_by_xpath("//android.widget.MultiAutoCompleteTextView \
[contains(@text,'接收者')]")
input_number.clear()
input_number.send_keys("5556")
input_text = self.driver.find_element_by_xpath("//android.widget.EditText \
[contains(@text,'键入信息')]")
input_text.clear()
input_text.send_keys(u'短信测试')
# sleep(2)
# # text = input_text.text.encode('UTF-8')
# # print text
self.driver.find_element_by_xpath("//android.widget.ImageButton \
[contains(@content-desc,'发送')]").click()
if __name__=="__main__":
# testunit=unittest.TestSuite()
# testunit.addTest(SMS("test_send_message"))
# filename="./test_results\\result.html"
# fp=file(filename,'wb')
# runner=HTMLTestRunner.HTMLTestRunner(stream=fp,title='test_result',description='send message result')
# runner.run(testunit)
# fp.close()
unittest.main()
代码如上,运行代码后,input_text.send_keys(u'短信测试') 未执行成功,没有向输入框中键入 “短信测试”,也未成功发送短信。希望给位能告知一下中文输入如何实现。
PS:百度 appium 输入中文,结果大都是设置 unicodeKeyboard,resetKeyboard 的值,但是这两个值我都已经设置过了。。。