appium+allure+pytest

1、环境搭建

    brew install allure

    npm install  appium

    pip3 install pytest

    pip3 install allure-pytest

    pip3 install pytest-allure-adaptor

    sudo pip3 install Appium-Python-Client

 

2、设备信息

(使用yaml格式,多个设备信息放一个yaml文件里)

-
  deviceDesc: Honor_8
  server_url: 127.0.0.1
  server_port: 4723
  desired_caps:
    platformName: Android
    platformVersion: 8.0.0
    deviceName: xxxxxx
    appPackage: xxxxxx
    appActivity: .ui.MainActivity
    noReset: True
    automationName: UiAutomator2
    systemPort: 8200
-
  deviceDesc: Mi_6X
  server_url: 127.0.0.1
  server_port: 4724
  desired_caps:
    platformName: Android
    platformVersion: 9
    deviceName: xxxxxxx
    appPackage: xxxxxxx
    appActivity: .ui.MainActivity
    noReset: True
    automationName: Uiautomator2
    systemPort: 8203

 

3、定义driver和device   

    class BaseDriver:
       def base_driver(self, device, automationName='UiAutomator2', noReset=True):
         path = caps_dir
         with open(path, encoding='utf-8') as fs:
            datas = yaml.load(fs, Loader=yaml.FullLoader)
        for i in datas:
            if device == i['deviceDesc']:
                if noReset == False:
                    i['desired_caps']['noReset'] = False
                desired_caps = i['desired_caps']
                driver = webdriver.Remote('http://{0}:{1}/wd/hub'.format(i['server_url'], i['server_port']), desired_caps)
                return driver, device

4、全局conftest.py文件

    params=[deviceDesc]

    @pytest.fixture(params=params)
    def execute_driver(request):
        driver = BaseDriver().base_driver(device=request.param)
        yield driver
        driver[0].close_app()
        driver[0].quit()

 

5、main.py文件

    curTime = time.strftime('%Y-%m-%d_%H-%M-%S')
    pytest.main([
    '-s', '-q',
    '-p','no:warnings',
    # '--reruns','1',
    '--alluredir', htmlreports_dir + '/app_AutoTest_Reports_{0}'.format(curTime),
    ])

 

6、生成report

    allure generate HtmlTestReports/xxxx_Reports_2019-10-30_19-30-16/ -o report

 


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值