Appium脚本(3):sendkey(封装capability)

输入中文注意添加这个配置,否正中文输入不了
desired_caps['unicodeKeyboard'] = "True"
desired_caps['resetKeyboard'] = "True"

capability.py

 1 from appium import webdriver
 2 
 3 desired_caps = {}
 4 desired_caps['platformName'] = 'Android'
 5 desired_caps['deviceName'] = '127.0.0.1:62001'
 6 desired_caps['platforVersion'] = '5.1.1'
 7 
 8 # 真机配置
 9 # desired_caps['deviceName']='MX4'
10 # desired_caps['platforVersion']='5.1'
11 # desired_caps['udid']='750BBKL22GDN'
12 
13 # desired_caps['app'] = r'C:\python_dir\apps\kaoyan3.1.0.apk'
14 desired_caps['appPackage'] = 'com.tal.kaoyan'
15 desired_caps['appActivity'] = 'com.tal.kaoyan.ui.activity.SplashActivity'
16 
17 # 重置开关,默认false,默认每次如第一次安装好的状态
18 desired_caps['noReset'] = 'True'
19 
20 # 中文输入
21 desired_caps['unicodeKeyboard'] = "True"
22 desired_caps['resetKeyboard'] = "True"
23 
24 driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
25 driver.implicitly_wait(3)

 

sendkey_3.py

 1 from app.find_element.capability import driver
 2 
 3 accunt_input = driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext')
 4 accunt_input.clear()
 5 accunt_input.send_keys("账号123")
 6 passwd_input = driver.find_element_by_id('com.tal.kaoyan:id/login_password_edittext')
 7 passwd_input.send_keys('123')
 8 driver.implicitly_wait(3)
 9 driver.find_element_by_id('com.tal.kaoyan:id/login_login_btn').click()
10 
11 driver.close_app()

 

posted @ 2019-05-23 14:11  星瑞  阅读(789)  评论(0编辑  收藏  举报