示例#1
0
 def __init__(self, file_path=None):
     if file_path:
         self.yaml_path = file_path
     else:
         self.yaml_path = "../yamlFile/desired_caps.yaml"
     # self.mysql_yaml_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config/mysql.yaml")
     self.log = Log()
示例#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
文件: 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)
示例#5
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)
示例#6
0
class BaseFun:
    def __init__(self, driver):
        self.driver = driver
        self.log = Log()
        print(id(self.driver))

    def find_element(self, loc, timeout=60):
        try:
            ele = WebDriverWait(self.driver, timeout).until(
                EC.presence_of_element_located(loc))
            return ele
        except Exception as e:
            self.log.error("获取元素时失败,失败原因__{}__".format(e))

    def clear(self, loc):
        self.find_element(loc).clear()

    def send_keys(self, loc, text):
        self.find_element(loc).send_keys(text)

    def click(self, loc):
        self.find_element(loc).click()

    def get_text(self, loc):
        return self.find_element(loc).text

    def maximizewindow(self):
        self.driver.maximize_window()

    def get_url(self, url):
        self.driver.get(url)

    def wait(self, sec):
        self.driver.implicitly_wait(sec)

    def quit(self):
        self.driver.quit()
示例#7
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)
示例#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 _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()
示例#10
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Public.BasePage import BasePage
from Public.Decorator import *
import unittest

from Public.ReadConfig import ReadConfig
from PageObject import creation, camera, login, community
from Public.Test_data import *
from Public.Log import Log
log = Log()

apk_url = ReadConfig().get_apk_url()
apk = get_apk()
pkg_name = ReadConfig().get_pkg_name()


class community_userinfo(unittest.TestCase, BasePage):
    '''社区相关 用户空间测试'''

    # @classmethod
    # @setupclass
    # def setUpClass(cls):
    #     cls.d.app_stop_all()
    #
    # @classmethod
    # @teardownclass
    # def tearDownClass(cls):
    #     cls.d.app_stop("com.quvideo.xiaoying")
    #
    @setup
示例#11
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from Public.Decorator import *
from Public.Log import Log

log = Log()


class vip_page(BasePage):
    @teststep
    def is_vip_page(self):
        log.i('判断是否在VIP页面')
        status = self.d(text="使用兑换码").wait(timeout=5)
        log.i('status=%s' % status)
        return status

    @teststep
    def vip_back(self):
        log.i('从VIP页面返回首页')
        self.d(resourceId="com.quvideo.xiaoying:id/iv_back").click()

    @teststep
    def click_server_btn(self):
        log.i('vip页面,点击客服按钮')
        self.d(resourceId="com.quvideo.xiaoying:id/vip_home_service_text"
               ).click()
示例#12
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()
示例#13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

sys.path.append('..')

import logging
from Public.CaseStrategy import CaseStrategy
from Public.RunCases import RunCases
from Public.configEmail import Email
from Public.Log import Log

if __name__ == '__main__':
    Run = RunCases()
    # 创建报告地址
    report_path = Run.create_path()
    report_name = report_path + '/' + 'TestReport.html'
    # 创建Log
    log = Log()
    log.set_logger(report_path)
    # 创建用例
    cs = CaseStrategy()
    cases = cs.collect_cases(suite=False)
    # 运行测试
    Run.run(report_name, cases)
    # 发送邮件
    # email = Email()
    # email.send_email_bySelf(report_name)
示例#14
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())

        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()
示例#15
0
文件: studio.py 项目: zlmone/ATX-UI
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from Public.Decorator import *
from Public.Log import Log
from PageObject.VivaVideo import home, gallery, publish
log = Log()


class studio_page(BasePage):
    '''工作室页面'''
    @teststeps
    def create_draft(self):
        log.i('创建一个草稿工程')
        home.home_Page().click_edit_btn()
        gallery.gallery_page.gallery_clip_add(2)
        publish.publish_page().click_draft_btn()

    @teststep
    def select_draft(self):
        log.i('打开一个草稿工程')
        try:
            self.d(resourceId="com.quvideo.xiaoying:id/rl_studio_draft_item"
                   ).click(3)
        except:
            log.i('当前没有草稿工程,新建一个草稿')
            home.home_Page().click_home_btn()
            self.create_draft()
            self.d(resourceId="com.quvideo.xiaoying:id/rl_studio_draft_item"
                   ).click()
示例#16
0
class ReadFile:
    # 初始化yaml地址
    def __init__(self, file_path=None):
        if file_path:
            self.yaml_path = file_path
        else:
            self.yaml_path = "../yamlFile/desired_caps.yaml"
        # self.mysql_yaml_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config/mysql.yaml")
        self.log = Log()

    # 读取yaml文件
    def read_yaml(self):
        try:
            file_path = self.yaml_path
            # if path_type == "yaml_path":
            #     file_path = self.yaml_path
            # elif path_type == "mysql_path":
            #     file_path = self.mysql_yaml_path
            # else:
            #     print("文件类型输入错误")
            """
            open与with open区别在于 open不关闭 需要手动f.close()
            with open会自动关闭
            """
            # f = open("file","r",encoding="utf-8")
            # print(yaml.load(f.read()))
            with open(file_path, "r", encoding="utf-8") as f:
                return yaml.load(f.read(), Loader=yaml.FullLoader)
        except Exception as e:
            print("读取文件报错{}".format(e))
            self.log.error("读取文件报错{}".format(e))

    # 读取excel文件
    def read_excel(self, sheet_name, function, casename=None, excel_path=None):
        if excel_path:
            excel_path = excel_path
        else:
            excel_path = self.excel_path
        """
        读取excel
        :param sheet_name:
        :param function:
        :param casename:
        :return:
        """
        try:
            book = xlrd.open_workbook(excel_path)
            data = book.sheet_by_name(sheet_name)
            param = []
            # print("列数:%s" % data.nrows)
            for i in range(0, data.nrows):
                get_func_name = data.row_values(i)[0]
                get_run = data.row_values(i)[3]
                get_cas_name = data.row_values(i)[1]
                if casename is None:
                    if get_func_name == function and get_run == 1:
                        param.append(data.row_values(i))
                else:
                    if get_func_name == function and get_cas_name == casename and get_run == 1:
                        param.append(data.row_values(i))
            return param
        except Exception as e:
            print("读取excel报错{}".format(e))
示例#17
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()
示例#18
0
 def __init__(self, driver):
     self.driver = driver
     self.log = Log()
     print(id(self.driver))