appium 2.0 beta版体验
  54wKHQuU2AYM 2023年11月14日 21 0

appium 创建了Appium 2.0的项目看板,项目正在开发中。

https://github.com/appium/appium/projects/2

Appium 2.0 核心特性

  • 独立的驱动:能够安装和使用基于你的应用平台的解耦的驱动程序。(iOS, Android, Windows OS, Flutter, etc.)

我们知道Appium为了支持多平台,集成了各种驱动在里面,使他变得比较笨重,我们在使用Appium的时候往往只完成一两个平台的测试,Appium 2.0 就可以按照需求去安装平台驱动。

例如,只做iOS测试,可以只安装xcuitest。

> appium driver install xcuitest
  • 插件生态: 能够通过插件和与其他技术的集成来修改Appium框架。

除了驱动可以根据需求安装,另外一些能力可以通过插件的方式提供安装。

例如,想使用报告插件,可以安装appium-reporter-plugin.

> appium plugin install --source=npm appium-reporter-plugin

Appium 2.0 安装

  • 升级npm

npm 版本需要大于8.x。

> npm install -g npm
  • 安装appium
> npm install -g appium@next

这是全局的安装方式,如果你正在使用appium 1.x,可以创建一个目录,使用局部安装。

> npm install appium@next
  • 检查版本
> appium --version
2.0.0-beta.43
  • 查看驱动
> appium driver list

✔ Listing available drivers
- uiautomator2 [not installed]
- xcuitest [not installed]
- youiengine [not installed]
- windows [not installed]
- mac [not installed]
- mac2 [not installed]
- espresso [not installed]
- tizen [not installed]
- flutter [not installed]
- safari [not installed]
- gecko [not installed]
  • 安装驱动
appium driver install uiautomator2
  • 安装报告插件
> appium plugin install --source=npm appium-reporter-plugin

appium 2.0 使用

  • 使用插件的方式启动appium
> appium --use-plugins=appium-reporter-plugin
...
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[Appium] Available drivers:
[Appium]   - espresso@2.8.3 (automationName 'Espresso')
[Appium]   - uiautomator2@2.4.7 (automationName 'UiAutomator2')
[Appium] Available plugins:
[Appium]   - gestures@1.0.0-beta.4
[Appium]   - appium-reporter-plugin@1.0.0-beta.7 (ACTIVE)

编写自动规划用例:

# test_sample.py
import unittest
from time import sleep
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy


class TestBBS(unittest.TestCase):

    def setUp(self):
        desired_caps = {
            'deviceName': 'JEF_AN20',
            'automationName': 'UiAutomator2',
            'platformName': 'Android',
            'platformVersion': '10.0',
            'appPackage': 'com.meizu.flyme.flymebbs',
            'appActivity': '.ui.LoadingActivity',
            'noReset': True,
        }

        self.dr = webdriver.Remote(
            command_executor='http://127.0.0.1:4723',
            desired_capabilities=desired_caps)

    def tearDown(self):
        self.dr.quit()

    def test_bbs(self):
        # 定义运行环境
        sleep(5)
        self.dr.find_element(MobileBy.ID, "com.meizu.flyme.flymebbs:id/nw").click()
        sleep(2)
        self.dr.find_element(MobileBy.ID, "com.meizu.flyme.flymebbs:id/nw").send_keys("flyme")
        self.dr.find_element(MobileBy.ID, "com.meizu.flyme.flymebbs:id/o1").click()
        sleep(2)

        title_list = self.dr.find_elements(MobileBy.ID, "com.meizu.flyme.flymebbs:id/a29")
        for title in title_list:
            print(title.text)
            self.assertIn("lyme", title.text)


if __name__ == '__main__':
    unittest.main()
  • 运行测试
> python test_sample.py

问题

  1. appium 服务地址:http://127.0.0.1:4723, 后面不要加:/wd/hub
  2. appium-reporter-plugin 插件从名字看是生成报告的,我们知道测试报告一定是和测试框架绑定的一个概念,事实告诉我没那么简单。

appium-reporter-plugin assumes every test/spec uses new driver session. For commands invoked on the driver session, screenshot and metrics are captured at server side. At the end of the test i.e., before deleting the driver session, driver.setTestInfo(..) should be called to map test information. After all the tests are completed driver.getReport() can be called to fetch the html report and written to file.

时间原因,我也没再去倒腾~!插件地址:

https://github.com/AppiumTestDistribution/appium-reporter-plugin

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月14日 0

暂无评论

推荐阅读
  xaeiTka4h8LY   2024年05月17日   44   0   0 MySQLgithub
54wKHQuU2AYM