def get_android_devices(): android_devices_list = [] for device in Shell.invoke('adb devices').splitlines(): if 'device' in device and 'devices' not in device: device = device.split('\t')[0] android_devices_list.append(device) return android_devices_list
def __init__(self): L.i('__init__ Environment...') self.devices = Shell.get_android_devices() self.appium_v = Shell.invoke('appium -v').splitlines()[0].strip() self.config = Config() self.check_environment() self.save_environment()
run case with key word: python3 run.py -k <keyword> """ if __name__ == '__main__': env = Environment() xml_report_path = env.get_environment_info().xml_report html_report_path = env.get_environment_info().html_report # 开始测试 args = [ '-s', '-q', '--allure_features=My stdio1', '--alluredir', xml_report_path ] # args = ['-s', '-q'],'--allure_features=My stdio' self_args = sys.argv[1:] pytest.main(args) # 生成html测试报告 cmd = 'allure generate %s -o %s' % (xml_report_path, html_report_path) # try: Shell.invoke(cmd) except: L.e("Html测试报告生成失败,确保已经安装了Allure-Commandline") # 查找html报告并发送 # time.sleep(2) # from utils.mail import Mail # mail = Mail() # mail.sendMail()
# new_user_view_video() # login() test_new_user_view_live() # getSide() # swipeUp(500, 3) if __name__ == '__main__': xml_report_path = "./allure-results" html_report_path = "./allure-results/html" # 开始测试 args = ["test.py", '-s', '-q', '--alluredir', xml_report_path] pytest.main(args) args = ["test.py", '-s', '-q', '--alluredir', xml_report_path] pytest.main(args) # 生成html测试报告 cmd1 = 'allure generate %s -o %s' % (xml_report_path, html_report_path) cmd2 = 'allure open ' + html_report_path try: Shell.invoke(cmd1) Shell.invoke(cmd2) except: L.e("Html测试报告生成失败,确保已经安装了Allure-Commandline") # try : # Shell.invoke("allure serve --profile ./") # except: # L.e("Html测试报告生成失败,确保已经安装了Allure-Commandline") #
# -*- coding: utf-8 -*- from utils.shell import Shell from utils.shell import ADB appium_v = Shell.invoke('appium -v') print(appium_v)