1. 需要在配置信息中增加'unicodeKeyboard' = “True”字段,如下:
def driver_weixin(platformVersion="6.0.1",deviceName='Galaxy A8'):
desired_caps2 = {}
desired_caps2['platformName'] = "Android"
desired_caps2['platformVersion'] = platformVersion
desired_caps2['deviceName'] = deviceName
desired_caps2['udid'] = "75a2daf1"
#desired_caps2['automationName'] = 'UiAutomator2'
desired_caps2['appPackage'] = 'com.tencent.mm'
desired_caps2['appActivity'] = 'com.tencent.mm.ui.LauncherUI'
desired_caps2['resetKeyboard'] = "True" #隐藏键盘
desired_caps2['unicodeKeyboard'] = "True"
return desired_caps2
2.测试代码中加入
self.driver = webdriver.Remote("http://127.0.0.1:4725/wd/hub", desired_caps2) element = self.driver.find_element_by_xpath(xxxxx) SendContent = "我爱中华" element.send_keys(u"%s" % SendContent)