from appium import webdriver
desired_caps = {}
desired_caps["platformName"] = 'Android' #连接的手机名字
desired_caps['deviceName'] = '127.0.0.1:62001' #连接的ip名字或者真机的udid
desired_caps['platformVersion'] = '4.4.2' #手机的型号
desired_caps['app'] = r'C:\Users\123\Desktop\Testing Set\app_test\kaoyanbang_3.3.6.242.apk' #如果要安装就解开封印
desired_caps['appPackage'] = 'com.tal.kaoyan'
desired_caps['appActivity'] = 'com.tal.kaoyan.ui.activity.SplashActivity' #和上面一条一起就是找到包并打开应用
desired_caps['noReset'] = 'True' #False/True在此会话之前不要重置应用程序状态
desired_caps['unicodeKeyboard'] = 'True' #使用unicode输入法,输入中文
desired_caps['resetKeyboard'] = 'True' #恢复键盘
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',desired_caps) #连接服务器
driver.implicitly_wait(5) #等待5s
2.再写一个kyb_login.py
from appium_one.lianjie import driver
def login():
driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext').clear()
driver.find_element_by_id('com.tal.kaoyan:id/login_email_edittext').send_keys('自学网2018')
driver.find_element_by_id('com.tal.kaoyan:id/login_password_edittext').send_keys('zxw2018')
driver.find_element_by_id('com.tal.kaoyan:id/login_login_btn').click()
def tv_skip():
try:
a = driver.find_element_by_id('com.tal.kaoyan:id/tv_skip')
except:
print("没有跳过按钮")
else:
a.click()
print('点击跳过')
def null_login():
try:
driver.find_element_by_id('com.tal.kaoyan:id/mainactivity_button_mysefl')
except:
print('kaishidenglu l ')
login()
else:
driver.find_element_by_id('com.tal.kaoyan:id/mainactivity_button_mysefl').click()
driver.find_element_by_id('com.tal.kaoyan:id/activity_usercenter_username').click()
login()
if __name__ == '__main__':
tv_skip()
null_login()
#判断有没有一些按钮,有就点,没有就跳过