Exemplo n.º 1
0
 def __init__(self, kw):
     _init = {"driver": kw["driver"], "test_msg": get_yaml(kw["path"])}
     self.page = PagesObjects(_init)
Exemplo n.º 2
0
# -*- coding: UTF-8 -*-
# author:ysl
# 2019-10-11

import os
import unittest
import ddt
from Base.BaseYaml import get_yaml

PATH = lambda p: os.path.abspath(os.path.join(os.path.dirname(__file__), p))


@ddt.ddt
class TestTest(unittest.TestCase):
    def setUp(self):
        print("start")

    def tearDown(self):
        print("end")

    @ddt.file_data("../Yamls/Test.yaml")
    def test_a(self, value):
        print(value)


if __name__ == '__main__':
    print(get_yaml("../Yamls/Test.yaml"))
    unittest.main()
Exemplo n.º 3
0
    device_info = DeviceInfo().device_info

    # appium连接手机
    ins = AppInit(args.device, app)
    ins.start(reset=args.reset, reinstall=args.reinstall, start_appium=args.start_appium,
              implicitly_wait=args.imp)

    # pytest命令参数
    report_file = rf'{product_path}/report/{config_info.session_id}/{dir_time}/{report_name}.html'
    pytest_args = [rf'--html={report_file}', '--self-contained-html', f'--reruns={args.reruns}']

    # 使用testsuite.yaml定义的用例运行
    parent_case_dir = rf'{product_path}/testcase/app/'
    if args.testsuite:
        suite_path = f'{parent_case_dir}{args.testsuite}'
        for testcase in get_yaml(suite_path)['testcase']:
            if isinstance(testcase, list):
                testcase = testcase[0]
            pytest_args.append(parent_case_dir + testcase)  # 加入用例参数
    # 指定用例目录或用例文件运行
    elif args.dir:
        dir_list = args.dir.split(' ')
        for d in dir_list:
            each_case_dir = parent_case_dir + d
            pytest_args.append(each_case_dir)
    # 不定义testsuite和dir,使用默认目录运行
    else:
        pytest_args.append(parent_case_dir)
    # 添加用例标记
    if args.m:
        pytest_args.append(f'-m {args.m}')
Exemplo n.º 4
0
from Base.BaseYaml import get_yaml
from Base.BaseConfig import ConfigInfo
from Base.BaseMysql import DbConn
import os

# ————————————————以下项一般不建议修改——————————————————
dir_name = os.path.dirname(__file__)
f = get_yaml(dir_name + '/config.yaml')
product = f['product']
env = f['env']
config_info = ConfigInfo(product, env)
product_path = config_info.product_path
db = DbConn(product, env)


# ————————————————以下项可根据需要增删改——————————————————
def get_user_info(account=None):
    login_info = f['login_info'][env]
    corp_id = login_info['corp_id']
    # 如果指定用户名,则获取指定用户密码,否则获取全部
    u_p_info = login_info['u_p']
    if account:
        if account in u_p_info:
            password = u_p_info[account][0]
            username = u_p_info[account][1]
            return [corp_id, account, password, username]
        else:
            raise KeyError('配置文件不存在该用户名,请检查')
    else:
        result = []
        for account in u_p_info:
Exemplo n.º 5
0
 def __init__(self):
     path = root_path + r"/config/devices.yaml"
     self.device_info = get_yaml(path)
     self.webview_file = root_path + r"/config/device_webview"
     self.adb = AndroidDebugBridge()
Exemplo n.º 6
0
 def __init__(self, product=None, env=None):
     self.product = product
     self.env = env
     self.product_path = root_path + '/product/' + self.product
     self.all = get_yaml(self.product_path + '/config/config.yaml')
     self.my_db = self.product_path + '/config/my_db'
Exemplo n.º 7
0
                    type=int)
parser.add_argument('--reset', help='是否重置app,默认1(是)', default=1, type=int)
parser.add_argument('--reinstall',
                    help='是否重新安装app,默认0(否)',
                    default=0,
                    type=int)
parser.add_argument('--imp', help='隐式等待时间,默认1秒', default=1, type=int)

args_p = parser.parse_args()
print(args_p)
product = args_p.product
env = args_p.env
start_appium = args_p.start_appium
# 获取批量运行配置信息
config_info = ConfigInfo(product, env)
args_file = get_yaml(config_info.product_path + '/config/batch_run_app.yaml')
reruns = int(args_file['reruns'])
run_args = args_file['run_args']
# 会话id
session_id = f'{dir_time}_{randint(10, 99)}'


# 启动方法
def run(device, run_mode, mode_args):
    cmd = rf'start python {root_path}/run_app.py {product} {env} {device} {run_mode} "{mode_args}" --session {session_id} ' \
        rf'--batch 1 --reruns {reruns} --start_appium {start_appium} --reset {args_p.reset} --reinstall {args_p.reinstall} ' \
        rf'--imp {args_p.imp}'
    print(cmd)
    os.system(cmd)