def run(line): try: if line[3] == 'caps': app.update_capability(line[4], line[5]) return if line[3] == 'start': app.start(line[4], line[5]) return if line[3] == 'sleep': app.sleep(line[4]) return if line[3] == 'swip': app.swip(line[4], line[5]) return if line[3] == 'id': app.get_element("id", line[4], line[5], line[6]) return if line[3] == 'name': app.get_element("name", line[4], line[5], line[6]) return if line[3] == 'text': app.get_element("text", line[4], line[5], line[6]) return if line[3] == 'css': app.get_element("css", line[4], line[5], line[6]) return if line[3] == 'xpath': app.get_element("xpath", line[4], line[5], line[6]) return if line[3] == 'class': app.get_element("class", line[4], line[5], line[6]) return if line[3] == 'click': app.clicks("click", line[4], line[5], line[6]) return if line[3] == 'clear': app.clicks("clear", line[4], line[5], line[6]) return if line[3] == 'input': app.clicks("input", line[4], line[5], line[6]) return if line[3] == 'assertequals': app.assertequals(line[4], line[5]) return if line[3] == 'savephoto': app.get_screenshot(resultfile, line[4]) return except BaseException as e: print(e.args) app.get_screenshot(resultfile + 'error_', line[4]) rerun(run)
#-文件目录配置---------------------------- #conf配置 srcfile = os.path.join(dataDir, 'myApp.xls') desfile = os.path.join(dataDir, 'myApp_result.xls') resultfile = os.path.join(reportDir, 'screenshot/screenshot_') print(dataDir, srcfile) #conf配置 srcfile = os.path.join(dataDir, 'myApp.xls') desfile = os.path.join(dataDir, 'myApp_result.xls') resultfile = os.path.join(reportDir, 'screenshot/screenshot_') print(dataDir, srcfile) #app.update_capability("appPackage","diankan") print(app.desired_caps) app.update_capability("deviceName", "6EB02175180042260") #app.update_capability("platformVersion","8.0") print(app.desired_caps) url = "http://localhost:4723/wd/hub" timeout = 10 print('正在启动...') app.start(url, timeout) print('启动客户端.....') time.sleep(5) print('打开客户端了') #启动页向左滑动
def run(line): if line[3] == 'caps': app.update_capability(line[4], line[5]) return if line[3] == 'start': print(app.desired_caps) app.start(line[4], line[5]) return if line[3] == 'sleep': app.sleep(line[4]) return if line[3] == 'right': app.RIGHT() return if line[3] == 'left': app.LEFT() return if line[3] == 'up': app.UP() return if line[3] == 'down': app.DOWN() return if line[3] == 'id': app.get_element("id", line[4], line[5], line[6], line[2]) return if line[3] == 'name': app.get_element("name", line[4], line[5], line[6], line[2]) return if line[3] == 'text': app.get_element("text", line[4], line[5], line[6], line[2]) return if line[3] == 'css': app.get_element("css", line[4], line[5], line[6], line[2]) return if line[3] == 'xpath': app.get_element("xpath", line[4], line[5], line[6], line[2]) return if line[3] == 'class': app.get_element("class", line[4], line[5], line[6], line[2]) return if line[3] == 'click': app.clicks("click", line[4], line[5], line[6], line[2]) return if line[3] == 'clear': app.clicks("clear", line[4], line[5], line[6], line[2]) return if line[3] == 'input': app.clicks("input", line[4], line[5], line[6], line[2]) return if line[3] == 'assertequals': app.assert_equals(line[4], line[5],line[6]) return if line[3] == 'savephoto': app.get_screenshot(resultfile, line[4]) return if line[3] == 'text': app.get_element("text", line[4], line[5], line[6], line[2]) return if line[3] == 'quit': app.quit() return if line[3] == 'back': app.back() return if line[3]=='pagesource': app.get_pages_source(line[4]) return if line[3] == 'assertequals_all': app.assert_equals_all(line[4], line[5],line[6]) return if line[3] == 'assertin': app.assert_in(line[4], line[5],line[6]) return if line[3] == 'toast': t.is_toast_exists(app.driver,line[4],line[5],line[6]) return if line[3] == 'alwaysallow': t.always_allow(app.driver,line[4]) return if line[3] == 'textContains': app.get_element("textContains", line[4], line[5], line[6], line[2]) return if line[3] == 'isexist': app.is_exists(line[4],line[5]) return if line[3] == 'tanchuang': app.tanchuang(line[4]) return if line[3] == 'backs': app.backs(line[4]) return if line[3]=='tappoint': app.tap_point(line[4],line[5]) return if line[3]=='taprandom': app.tap_random() return if line[3]=='pagesource': app.get_pages_source() return if line[3]=='sourceassert': app.source_assert(line[4]) return if line[3]=='activity': app.get_current_activity() return if line[3]=='getpack': adb.get_package() return else: print('没有这个方法,请检查',line[3]) return
def run(line): if line[3] == 'caps': app.update_capability(line[4], line[5]) return if line[3] == 'start': print(app.desired_caps) app.start(line[4], line[5]) return if line[3] == 'sleep': app.sleep(line[4]) return if line[3] == 'right': app.RIGHT() return if line[3] == 'left': app.LEFT() return if line[3] == 'up': app.UP() return if line[3] == 'down': app.DOWN() return if line[3] == 'id': app.get_element("id", line[4], line[5], line[6], line[2]) return if line[3] == 'name': app.get_element("name", line[4], line[5], line[6], line[2]) return if line[3] == 'text': app.get_element("text", line[4], line[5], line[6], line[2]) return if line[3] == 'css': app.get_element("css", line[4], line[5], line[6], line[2]) return if line[3] == 'xpath': app.get_element("xpath", line[4], line[5], line[6], line[2]) return if line[3] == 'class': app.get_element("class", line[4], line[5], line[6], line[2]) return if line[3] == 'click': app.clicks("click", line[4], line[5], line[6], line[2]) return if line[3] == 'clear': app.clicks("clear", line[4], line[5], line[6], line[2]) return if line[3] == 'input': app.clicks("input", line[4], line[5], line[6], line[2]) return if line[3] == 'assertequals': app.assertequals(line[4], line[5]) return if line[3] == 'savephoto': app.get_screenshot(resultfile, line[4]) return if line[3] == 'quit': app.quit() return if line[3] == 'back': app.back() return if line[3]=='pagesource': app.get_pages_source(line[4])
#引用你需要调试的文件 #举例如下 from common import elementApp as app # desired_caps = {} # desired_caps['platformName'] = 'Android' # desired_caps['platformVersion'] = '8.0.0' # desired_caps['deviceName'] = 'LMX4C17A28015459' # desired_caps['appPackage'] = 'com.dzmf.zmfxsdq' # desired_caps['appActivity'] = 'com.dzbook.activity.SplashActivity' # desired_caps['newCommandTimeout'] = '200' # desired_caps['automationName'] = 'UiAutomator2' #定义你的设备信息 app.update_capability('platformName', 'Android') app.update_capability('platformVersion', '8.0.0') app.update_capability('deviceName', 'LMX4C17A28015459') app.update_capability('appPackage', 'com.aikan') app.update_capability('appActivity', 'com.dzbook.activity.LogoActivity') app.update_capability('automationName', 'UiAutomator2') #引用你要调试的文件中的driver app.start('http://localhost:4723/wd/hub', 30) driver = app.driver def RELINK(): global driver driver = app.driver
def run(line): if line[3] == 'caps': app.update_capability(line[4], line[5]) return if line[3] == 'start': print(app.desired_caps) app.start(line[4], line[5]) return if line[3] == 'sleep': app.sleep(line[4]) return if line[3] == 'right': app.swiptest("right", line[4]) return if line[3] == 'left': app.swiptest("left", line[4]) return if line[3] == 'up': app.swiptest("up", line[4]) return if line[3] == 'down': app.swiptest("down", line[4]) return if line[3] == 'id': app.get_element("id", line[4], line[5], line[6], line[2]) return if line[3] == 'name': app.get_element("name", line[4], line[5], line[6], line[2]) return if line[3] == 'text': app.get_element("text", line[4], line[5], line[6], line[2]) return if line[3] == 'css': app.get_element("css", line[4], line[5], line[6], line[2]) return if line[3] == 'xpath': app.get_element("xpath", line[4], line[5], line[6], line[2]) return if line[3] == 'class': app.get_element("class", line[4], line[5], line[6], line[2]) return if line[3] == 'click': app.clicks("click", line[4], line[5], line[6], line[2]) return if line[3] == 'clear': app.clicks("clear", line[4], line[5], line[6], line[2]) return if line[3] == 'input': app.clicks("input", line[4], line[5], line[6], line[2]) return if line[3] == 'savephoto': app.get_screenshot(resultfile, line[4]) return if line[3] == 'text': app.get_element("text", line[4], line[5], line[6], line[2]) return if line[3] == 'quit': app.quit() return if line[3] == 'back': app.back() return if line[3] == 'pagesource': app.get_pagesource(line[4]) return if line[3] == 'assertequal': app.assert_method("equal", line[4], line[5], line[6]) return if line[3] == 'assertin': app.assert_method("in", line[4], line[5], line[6]) return if line[3] == 'assertnotequal': app.assert_method("notequal", line[4], line[5], line[6]) return if line[3] == 'assertnotin': app.assert_method("notin", line[4], line[5], line[6]) return if line[3] == 'assert_all_e': app.assert_all_method("equal", line[4], line[5], line[6]) return if line[3] == 'assert_all_in': app.assert_all_method("in", line[4], line[5], line[6]) return if line[3] == 'assertin_allnot_e': app.assert_all_method("notequal", line[4], line[5], line[6]) return if line[3] == 'assertin_allnot_in': app.assert_all_method("notin", line[4], line[5], line[6]) return if line[3] == 'toast': t.is_toast_exists(app.driver, line[4], line[5], line[6]) return if line[3] == 'alwaysallow': t.always_allow(app.driver, line[4]) return if line[3] == 'textContains': app.get_element("textContains", line[4], line[5], line[6], line[2]) return if line[3] == 'isexist': app.xpath_exist(line[4], line[5]) return if line[3] == 'tanchuang': app.tanchuang(line[4]) return if line[3] == 'tanchuangall': app.tanchuang_all() return if line[3] == 'backs': app.backs(line[4]) return if line[3] == 'tappoint': app.tap_point(line[4], line[5]) return if line[3] == 'taprandom': app.tap_random() return if line[3] == 'pagesource': app.get_pagessource(line[4]) return if line[3] == 'sourceassert': app.source_assert(line[4]) return if line[3] == 'activity': app.get_current_activity() return if line[3] == 'get_velue': app.get_value(line[4], line[5]) return else: print('没有这个方法,请检查', line[3]) return
# coding:utf-8 from common import elementApp as app from common import readexcel as reader, writeexcel as writer from appium.webdriver.common.touch_action import TouchAction import time import os import random from conf.conf import dataDir,reportDir,pageDir,imageDir from common import elementApp as app from module import pil_common as image #定义你的设备信息 app.update_capability('platformName','Android') app.update_capability('platformVersion','8.0.0') #9 app.update_capability('deviceName','SNMBB18417516563') #UYT0218209004285 app.update_capability('appPackage','com.ishugui') app.update_capability('appActivity','com.dzbook.activity.LogoActivity') app.update_capability('automationName','UiAutomator2') app.update_capability('appActivity','com.dzbook.activity.LogoActivity') app.update_capability('automationName','UiAutomator2') #引用你要调试的文件中的driver app.start('http://*****:*****@text='我的']" el=driver.find_element_by_xpath(xpath).click()
from appium.webdriver.common.touch_action import TouchAction import time import os import random # -文件目录配置---------------------------- filepath = os.path.abspath(os.getcwd()) srcfile = os.path.join(filepath, 'datadir/myApp.xls') desfile = os.path.join(filepath, 'datadir/myApp_result123.xls') resultfile = os.path.join(filepath, 'report/screenshot/screenshot_') print(srcfile) reader.open_excel(srcfile) writer.copy_open(srcfile, desfile) ''' app.update_capability("deviceName","UYT0218209004285") app.update_capability("platformVersion","9") app.desired_caps['unicodeKeyboard']=True app.desired_caps['resetKeyboard']=True print(app.desired_caps['unicodeKeyboard']) print(app.desired_caps['resetKeyboard']) ''' url = "http://localhost:4723/wd/hub" timeout = 10 print('正在启动...') app.start(url, timeout) print('启动客户端.....')
#引用你需要调试的文件 #举例如下 from common import elementApp as app # desired_caps = {} # desired_caps['platformName'] = 'Android' # desired_caps['platformVersion'] = '8.0.0' # desired_caps['deviceName'] = 'LMX4C17A28015459' # desired_caps['appPackage'] = 'com.dzmf.zmfxsdq' # desired_caps['appActivity'] = 'com.dzbook.activity.SplashActivity' # desired_caps['newCommandTimeout'] = '200' # desired_caps['automationName'] = 'UiAutomator2' #定义你的设备信息 app.update_capability('platformName', 'Android') app.update_capability('platformVersion', '6.0') app.update_capability('deviceName', 'T8B6W4LJU4VSQWWW') app.update_capability('appPackage', 'com.aikan') app.update_capability('appActivity', 'com.dzbook.activity.LogoActivity') #app.update_capability('automationName','UiAutomator2') #引用你要调试的文件中的driver app.start('http://localhost:4723/wd/hub', 30) driver = app.driver def RELINK(): global driver driver = app.driver