Пример #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(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)
Пример #3
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)
Пример #4
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()
Пример #5
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:
            # 运行前准备
            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
    @teststep
    def click_studio_img(self, inst=1):
        log.i('点击第%s个草稿' % inst)
        self.d(resourceId=
               "com.quvideo.xiaoying:id/xiaoying_studio_img_project_thumb",
               instance=inst - 1).click()
        time.sleep(2)

    @teststep
    def get_exported_status(self, inst=1):
        if self.d(resourceId=
                  "com.quvideo.xiaoying:id/xiaoying_studio_layout_bottom"
                  ).exists:
            status = self.d(resourceId="com.quvideo.xiaoying:id/xiaoying_studio_layout_top",instance=inst - 1).\
                child(resourceId="com.quvideo.xiaoying:id/xiaoying_studio_textview_exported").exists
        else:
            status =self.d(resourceId="com.quvideo.xiaoying:id/xiaoying_studio_layout_right",instance=inst - 1).\
                child(resourceId="com.quvideo.xiaoying:id/xiaoying_studio_textview_exported").exists

        return status


if __name__ == '__main__':
    from Public.Log import Log
    from PageObject import gallery

    Log().set_logger('udid', './log.log')
    BasePage().set_driver(None)

    log.i(studio_page().get_exported_status(4))