python做appui自动化_python appium app ui 自动化

#coding=utf-8

importreimporttimeimportyaml_inifrom appium importwebdriverfrom create_order importgenerate_orders_all#android app 版本信息

app_version : {'platformName': 'Android', #Android或iOS

'platformVersion': '5.1.1', #安卓版本

'deviceName': '127.0.0.1:62001 device', #手机设备名称,通过adb devices 查看

'appPackage': 'com.test.test', #用 aapt dump badging 查看包名

'appActivity': 'com.test.main_module.ui.SplashAt','newCommandTimeout': '200000'} #无操作是默认关闭时间

app_ip= yaml_ini.read_yaml()['app_ip']

app_version= yaml_ini.read_yaml()['app_version']

dr= webdriver.Remote('http://127.0.0.1:4723/wd/hub', app_version) #启动服务器地址,后面跟的是手机信息

deflogin():#输入账户密码

time.sleep(5)

dr.find_element_by_id('com.test.test:id/edt_phone').send_keys('')

dr.find_element_by_id('com.test.test:id/edt_pwd').send_keys('')

dr.find_element_by_id('com.test.test:id/tv_login').click()#输入短信验证码

time.sleep(3)

dr.find_element_by_id('com.test.test:id/txt_pin_entry1').send_keys('')

time.sleep(3)

dr.find_elements_by_class_name('android.widget.TextView')[3].click()#点击登陆

time.sleep(3)

dr.find_element_by_id('com.test.test:id/tv_open_latter').click()#不开启手势登陆

time.sleep(3)

dr.find_element_by_id('com.test.test:id/ivClose').click()#判断登陆是否成功

time.sleep(3)

login_data= dr.find_element_by_id('com.test.test:id/tv_online').textif '在线' inlogin_data:print('登陆成功')defstart_order():#开始接单

#time.sleep(3)

#dr.find_elements_by_class_name('android.widget.TextView')[34].click()

#抢单

generate_orders_all()

time.sleep(3)

dr.find_element_by_id('com.test.test:id/tv_grab').click()

time.sleep(3)

grab_result= dr.find_element_by_id('com.test.test:id/tv_status').textif '等待对方付款' ingrab_result:

grab_order_id= dr.find_element_by_id('com.test.test:id/tv_order_num_value').text

grab_order_money= dr.find_element_by_id('com.test.dcpay:id/tv_money_value').textprint('抢单成功:' + grab_order_id + ' ' +grab_order_money)

time.sleep(3)

dr.find_element_by_id('com.test.test:id/tv_confirm').click()

time.sleep(3)

send_money= dr.find_element_by_id('com.test.test:id/receive_amount').textif '请输入实际收款金额' insend_money:

time.sleep(3)

dr.find_element_by_id('com.test.test:id/receive_amount').click()

amount= (str(grab_order_money)).lstrip('¥')

dr.find_element_by_id('com.test.test:id/receive_amount').send_keys(amount)

time.sleep(3)

dr.find_element_by_id('com.test.test:id/receive_confirm').click()

time.sleep(3)

order_y_n= dr.find_element_by_id('com.test.test:id/tv_order_status').textif '交易成功' ==order_y_n:print('完成订单')

你可能感兴趣的:(python做appui自动化)