示例#1
0
    def _run_cases(server_url, run, cases, index):
        log = Log()
        log.set_logger(run.get_device()['udid'], run.get_path() + '/' + 'client.log')

        log.i('platformName: %s', run.get_device()['platformName'])
        log.i('udid: %s', run.get_device()['udid'])
        log.i('app: %s', run.get_device()['app'])
        log.i('reuse: %s\n', run.get_device()['reuse'])
        # log.i('autoAcceptAlerts: %s', run.get_device()['autoAcceptAlerts'])
        log.i('macaca server port: %d\n', run.get_port())

        # init driver
        driver = WebDriver(run.get_device(), server_url)
        driver.init()

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # login_status = LoginStatus()
        # login_status.set_status(False)

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        base_page.set_driver(driver)
        base_page.set_index(index)

        try:
            # run cases
            run.run(cases)
        except AssertionError as e:
            log.e('AssertionError, %s', e)

        # quit driver
        driver.quit()
示例#2
0
    def _run_cases(server_url, run, cases):
        log = Log()
        log.set_logger(run.get_device()['udid'],
                       run.get_path() + '\\' + 'client.log')

        log.i('platformName: %s', run.get_device()['platformName'])
        log.i('udid: %s', run.get_device()['udid'])
        log.i('package: %s\n', run.get_device()['package'])

        log.i('macaca server port: %d\n', run.get_port())

        # init driver
        driver = WebDriver(run.get_device(), server_url)
        driver.init()

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        base_page.set_driver(driver)

        # skip wizard
        if skip_wizard_to_home():
            # run cases
            run.run(cases)

        # quit driver
        driver.quit()
示例#3
0
    def _run_cases(run, cases):
        log = Log()
        log.set_logger(run.get_device()['model'], run.get_path() + '/' + 'client.log')
        log.i('udid: %s', run.get_device()['udid'])

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        # base_page.set_driver(run.get_device()['ip'])

        if 'ip' in run.get_device():
            base_page.set_driver(run.get_device()['ip'])
        else:
            base_page.set_driver(run.get_device()['serial'])

        try:
            # run cases
            base_page.set_fastinput_ime()

            run.run(cases)

            base_page.set_original_ime()
            base_page.unwatch_device()
            base_page.identify()
        except AssertionError as e:
            log.e('AssertionError, %s', e)
示例#4
0
    def _run_cases(run, cases):
        log = Log()
        log.set_logger(run.get_device()['model'],
                       os.path.join(run.get_path(), 'client.log'))
        log.i('udid: %s', run.get_device()['udid'])

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        if 'ip' in run.get_device():
            base_page.set_driver(run.get_device()['ip'])
        else:
            base_page.set_driver(run.get_device()['serial'])

        try:
            # run cases
            base_page.set_fastinput_ime()
            base_page.d.shell('logcat -c')  # 清空logcat

            run.run(cases)

            # 将logcat文件上传到报告
            base_page.d.shell('logcat -d > /sdcard/logcat.log')
            time.sleep(1)
            base_page.d.pull('/sdcard/logcat.log',
                             os.path.join(path.get_path(), 'logcat.log'))

            base_page.set_original_ime()
            base_page.identify()
        except AssertionError as e:
            log.e('AssertionError, %s', e)
示例#5
0
文件: Drivers.py 项目: zlmone/ATX-UI
    def _run_cases(run, cases):
        log = Log()
        log.set_logger(run.get_device()['model'],
                       run.get_path() + '/' + 'client.log')
        log.i('udid: %s' % run.get_device()['udid'])

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        # base_page.set_driver(run.get_device()['ip'])

        if 'ip' in run.get_device():
            base_page.set_driver(run.get_device()['ip'])
        else:
            base_page.set_driver(run.get_device()['serial'])

        try:
            # 运行前准备
            base_page.set_fastinput_ime()  # 设置fastime输入法
            # base_page.d.shell('rm -rf /sdcard/DCIM/XiaoYingLite')   # 删除之前的导出视频
            # base_page.d.shell('rm -rf /sdcard/XiaoYingLite')   # 删除之前的导出视频
            base_page.d.shell('logcat -c')  # 清空logcat
            # 开始执行测试
            run.run(cases)

            # 结束后操作
            base_page.unwatch_device()
            base_page.set_original_ime()
            base_page.identify()

            # 将logcat文件上传到报告
            base_page.d.shell('logcat -d > /sdcard/logcat.log')
            time.sleep(2)
            base_page.d.pull('/sdcard/logcat.log',
                             os.path.join(path.get_path(), 'logcat.log'))
            time.sleep(5)
            if ReadConfig().get_method().strip() in ["UDID", "SERVER2"]:
                log.i('release device %s ' % run.get_device()['serial'])
                atxserver2(ReadConfig().get_server_url()).release_device(
                    run.get_device()['serial'])
            else:
                pass
        except AssertionError as e:
            log.e('AssertionError, %s' % e)
示例#6
0
    def _run_maxim(run, cases, command, actions, widget_black):
        log = Log()
        log.set_logger(run.get_device()['model'],
                       os.path.join(run.get_path(), 'client.log'))
        log.i('udid: %s', run.get_device()['udid'])

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        if 'ip' in run.get_device():
            base_page.set_driver(run.get_device()['ip'])
        else:
            base_page.set_driver(run.get_device()['serial'])

        try:
            # run cases
            base_page.d.shell('logcat -c')  # 清空logcat
            if cases:
                run.run_cases(cases)
            Maxim().run_monkey(monkey_shell=command,
                               actions=actions,
                               widget_black=widget_black)

            base_page.d.shell('logcat -d > /sdcard/logcat.log')
            time.sleep(1)
            base_page.d.pull('/sdcard/logcat.log',
                             os.path.join(path.get_path(), 'logcat.log'))
            base_page.d.pull('/sdcard/monkeyerr.txt',
                             os.path.join(path.get_path(), 'monkeyerr.txt'))
            base_page.d.pull('/sdcard/monkeyout.txt',
                             os.path.join(path.get_path(), 'monkeyout.txt'))

            base_page.set_original_ime()
            base_page.identify()
            if ReadConfig().get_method().strip() in ["UDID", "SERVER2"]:
                log.i('release device %s ' % run.get_device()['serial'])
                atxserver2(ReadConfig().get_server_url()).release_device(
                    run.get_device()['serial'])
            else:
                pass
        except AssertionError as e:
            log.e('AssertionError, %s', e)
示例#7
0
    def _run_cases(server_url, run, cases):
        log = Log()
        # Windows
        # log.set_logger(run.get_device()['udid'], run.get_path() + '\\' + 'client.log')

        # MacOS
        log.set_logger(run.get_device()['udid'],
                       run.get_path() + '/' + 'client.log')

        log.i('platformName: %s', run.get_device()['platformName'])
        log.i('udid: %s', run.get_device()['udid'])
        # log.i('package: %s\n', run.get_device()['package'])
        log.i('bundleId: %s\n', run.get_device()['bundleId'])
        log.i('autoAcceptAlerts: %s\n', run.get_device()['autoAcceptAlerts'])
        log.i('macaca server port: %d\n', run.get_port())

        # init driver
        driver = WebDriver(run.get_device(), server_url)
        driver.init()

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        login_status = LoginStatus()
        login_status.set_status(False)

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        base_page.set_driver(driver)

        try:
            # skip wizard
            # if not into home page will raise AssertionError
            skip_wizard_to_home()

            # run cases
            run.run(cases)
        except AssertionError as e:
            log.e('AssertionError, %s', e)

        # quit driver
        driver.quit()
示例#8
0
    def _run_cases(run, cases):
        log = Log()
        log.set_logger(run.get_device()['model'],
                       run.get_path() + '/' + 'client.log')
        log.i('udid: %s', run.get_device()['udid'])

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        base_page.set_driver(run.get_device()['ip'])

        try:
            # run cases
            run.run(cases)
        except AssertionError as e:
            log.e('AssertionError, %s', e)
示例#9
0
def drive(server_url, run):
    log = Log()
    log.set_logger(run.get_device()['udid'], run.get_path() + '\\' + 'client.log')

    log.i('platformName: %s', run.get_device()['platformName'])
    log.i('udid: %s', run.get_device()['udid'])
    log.i('package: %s\n', run.get_device()['package'])

    log.i('macaca server port: %d\n', run.get_port())

    # init driver
    driver = WebDriver(run.get_device(), server_url)
    driver.init()

    # set cls.path, it must be call before operate on any page
    path = ReportPath()
    path.set_path(run.get_path())

    # set cls.driver, it must be call before operate on any page
    base_page = BasePage()
    base_page.set_driver(driver)

    while True:
        cmd = input("Please input run or exit:").lower()
        if cmd == 'run':
            print('Run run.py')
            print(os.system('python run.py %s %s %s %s'
                            % (run.get_port(),
                               run.get_device()['udid'],
                               run.get_path(),
                               driver.session_id
                               )
                            )
                  )
        elif cmd == 'exit':
            print('Good Bye')
            break

    # quit driver
    driver.quit()
示例#10
0
def init():
    port = int(sys.argv[1])
    udid = sys.argv[2]
    report_path = str(sys.argv[3])
    session = sys.argv[4]

    server_url = {
        'hostname': '127.0.0.1',
        'port': port,
    }

    log = Log()
    log.set_logger(udid, report_path + '\\' + 'client.log')

    driver = WebDriver('', server_url)
    driver.attach(session)

    # set cls.path, it must be call before operate on any page
    path = ReportPath()
    path.set_path(report_path)

    # set cls.driver, it must be call before operate on any page
    base_page = BasePage()
    base_page.set_driver(driver)