美文网首页
Appium Mac环境运行

Appium Mac环境运行

作者: 一钱科技 | 来源:发表于2019-10-08 09:16 被阅读0次
  • Appium安装
    1. 官网下载桌面版运行程序。直接安装运行
      Appium运行界面
  • python client安装
    官网下载最新版本Python,安装即可。
    # 查看版本号
    python3 
    
    # 安装client
    pip3 install Appium-Python-Client
    
  • PyCharm(可选):编辑器 官网

后续根据Appium UI自动化测试,进行编码测试。

生成HTML报告

  创建HTMLTestRunner_PY3文件,添加到python3.7 lib文件夹内

    # 选择指定时间格式
    timestr = time.strftime('%Y-%m-%d%H%M%S', time.localtime(time.time()))
    # 定义测试报告存放路径和报告名称
    report = os.path.join('/Users/mixiaoming/Downloads/report/test_report_' + timestr + '.html')
    with open(report, 'wb') as f:
        runner = HTMLTestRunner_PY3.HTMLTestRunner(stream=f, verbosity=2, title='云彩 - 自动化测试报告', description='执行人:App')
        runner.run(suite)
        # 关闭测试报告
        f.close()
截图

发生错误时,最方便的方式是进行截图。但是下面的方式对所有函数截图,需要调整

# 当前页面截屏
class take_screen_shot():  #这个类将在下面作为装饰器使用
    def __init__(self, func):
        self.func = func
        self.name = func.__name__ + ' (__main__.CalTestCase).png'  #拼接截图文件名

    def __call__(self, *args):   #对每次调用的函数都做截图操作
        try:
            self.func(self, *args)
        finally:
            DriverClient().get_driver().get_screenshot_as_file(配置.GlobalConfig.reportPath + "/" + self.name)
# 输入账号/密码
    @take_screen_shot
    def test_input_account_pwd(self):
        self.driver.find_element_by_id('com.qiumi.app.wallet:id/etTelephone').send_keys("13718863263")
        self.driver.find_element_by_id('com.qiumi.app.wallet:id/etPassword').send_keys("123456")
        return

相关文章

网友评论

      本文标题:Appium Mac环境运行

      本文链接:https://www.haomeiwen.com/subject/qsqsyctx.html