问题描述:
pycharm中执行测试用例,setup中设置desire_cap中添加了"unicodeKeyBoard": True,“resetKeyBoard”: True,但执行元素send_keys时无法录入中文。
- 环境:pycharm2020 + appium-python-client1.0.1+pytest+mumu模拟器2.3.9
- 移动端型号:mumu模拟器2.3.9
- 移动端系统:Android 6.0.1
- 问题复述:pycharm中执行测试用例,setup中设置desire_cap中添加了"unicodeKeyBoard": True,“resetKeyBoard”: True,但执行元素send_keys时无法录入中文。
相关log文件
直接将后缀名为.log的文件拖入输入框即可
相关代码(包括log文件,都要使用markdown代码格式,)
from appium import webdriver
import pytest
class TestXueqiu():
def setup(self):
desire_cap = {
"platformName": "Android",
"platformVersion": "6.0.1",
"deviceName": "127.0.0.1:7555",
"appPackage": "com.xueqiu.android",
"appActivity": "com.xueqiu.android.view.WelcomeActivityAlias",
"noReset": True,
"dontStopAppReset": True,
"skipDeviceInitialization": True,
# "automationName": "uiautomator2"
"unicodeKeyBoard": True,
"resetKeyBoard": True
}
self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desire_cap)
self.driver.implicitly_wait(20)
def teardown(self):
self.driver.back()
self.driver.back()
self.driver.quit()
def test_demo1(self):
print("搜索测试用例")
'''
1.打开 雪球
2.点击搜索输入框
3.向输入框中输入“阿里巴巴”,然后进行点击
4.获取这只香港 阿里巴巴的股价,并判断这只股份的价格>200
'''
# 搜索框元素
el1 = self.driver.find_element_by_id("com.xueqiu.android:id/tv_search")
el1.click()
#输入阿里巴巴
el2 = self.driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
el2.send_keys("阿里巴巴")
el3 = self.driver.find_element_by_xpath("//*[@resource-id='com.xueqiu.android:id/name' and @text='阿里巴巴']")
el3.click()
el4 = self.driver.find_element_by_id("com.xueqiu.android:id/current_price")
assert float(el4.text) > 200
if __name__ == '__main__':
pytest.main()
报错信息:
如果把el2.send_keys(“阿里巴巴”)改成el2.send_keys(“alibaba”)就是正常的,如下:
原因以及解决方式(没有可以写无):
无
原因:
无