Mac环境下OpenTest使用总结

运行环境:

node:20.5.1

npm:10.5.0

Java:1.8.0_351(如果存在多个版本Java,安装前将环境切换到jdk8)

安装

在终端输入命令

npm install opentest -g

开始

新建终端,输入命令:

cd ~
mkdir opentest
cd opentest
opentest quick-start
cd server
opentest server

再打开终端输入命令:

cd opentest/actor1
opentest actor

然后使用浏览器访问http://localhost:3000,即可看到后台界面

脚本

Web

修改opentest/actor1/actor.yaml文件中selenium配置

需修改的地方:

actorType:WEB
chromeDriverExePath: /opt/homebrew/bin/chromedriver

在opentest/test-repo/tests/web/目录新增需要测试的脚本,范例如下:

description: |
  baidu test
actors:
  - actor: WEB
    segments:
      - segment: 1
        actions:
          - description: Navigate to the baidu homepage
            action: org.getopentest.selenium.NavigateTo
            args:
              url: https://www.baidu.com/

          - description: Enter "hello" in the search box
            action: org.getopentest.selenium.SendKeys
            args:
              locator: {id: "kw"}
              text: hello
              sendEnter: true

          - description: Click the search button
            action: org.getopentest.selenium.Click
            args:
              locator: {id: "su"}

          - description: Close the current browser
            action: org.getopentest.selenium.CloseBrowser

Android

修改opentest/actor1/actor.yaml文件中appium配置

需修改的地方:

desiredCapabilities:
        fullreset: false
        platformName: android
        uiautomator2ServerInstallTimeout: 100000
        appium:platformVersion: "11"
        deviceName: R58M31RB17W
        automationName: UiAutomator2
        newCommandTimeout: 1000
        appActivity: com.atlasv.android.vidma.player.FirstActivity
        appPackage: vidma.mkv.xvideo.player.videoplayer.free
        autoGrantPermission: false
        noReset: true

在opentest/test-repo/tests/mobile/目录新增需要测试的脚本,范例如下:

description: |
  test player
actors:
  - actor: MOB
    segments:
      - segment: 1
        actions:
          - description: Click the Music tab
            action: org.getopentest.appium.Tap
            args:
              locator: { id: "vidma.mkv.xvideo.player.videoplayer.free:id/download" }

          - description: Close the app
            action: org.getopentest.appium.CloseApp

执行

Web

创建会话选中对应脚本即可

测试结果

Android

需先打开Appium Server,然后选中对应脚本即可

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值