def action2(): env = Environment().get_environment_info() capabilities = {'platformName': env.devices[0].platform_name, 'platformVersion': env.devices[0].platform_version, 'deviceName': env.devices[0].device_name, 'app': env.apk, 'clearSystemFiles': True, 'appActivity': env.app_activity, 'appPackage': env.app_package, 'automationName': 'UIAutomator2', 'noSign': True } host = "http://localhost:4723/wd/hub" driver = webdriver.Remote(host, capabilities) yield ElementActions(driver).reset(driver) driver.quit()
from Utils.Environment import Environment from Utils.Shell import Shell from Utils import Log import sys """ run all case: python run.py run one module case: python run.py test/test_home.py run case with key word: python 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', '--alluredir', xml_report_path] self_args = sys.argv[1:] pytest.main(args + self_args) # 生成html测试报告 cmd = "allure generate %s -o %s" % (xml_report_path, html_report_path) try: Shell.invoke(cmd) except: Log.e("Html测试报告生成失败,确保已经安装了Allure-Commandline")
def get_account(): account = Environment().get_inited_config().account_success pwd = Environment().get_inited_config().password_success L.d('账号:%s 密码 %s' % (account, pwd)) return [account, pwd]
def gen_page_py(): GenPages.gen_page_py() class WatchHandler(PatternMatchingEventHandler): patterns = ["*.yaml"] def on_modified(self, event): Log.i('监听到文件: yaml 发生了变化') try: gen_page_py() except Exception as e: Log.e('\n!!!!!!!---pages.yaml---!!!!!!\n解析文件 pages.yaml 错误\n' '请到{}路径下检查修改后重新保存.'.format(self.watch_path)) if __name__ == "__main__": event_handler = WatchHandler() full_path = Environment().get_environment_info().pages_yaml print(full_path) observer = Observer() observer.schedule(event_handler, full_path) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join()
# -*- coding: utf-8 -*- # @Pjname ; AppGuiTesting # @Time : 2020/05/21/17:49 # @Author : Yuye # @File : S.py from appium import webdriver from Base.Action import ElementActions from Utils.Environment import Environment env = Environment().get_environment_info() capabilities = { 'platformName': env.devices[0].platform_name, 'platformVersion': env.devices[0].platform_version, 'deviceName': env.devices[0].device_name, 'app': env.apk, 'clearSystemFiles': True, 'appActivity': env.app_activity, 'appPackage': env.app_package, 'automationName': 'UIAutomator2', 'noSign': True, 'newCommandTimeout': 60 * 100 } host = "http://localhost:4723/wd/hub" driver = webdriver.Remote(host, capabilities) action = ElementActions(driver)