运行环境:
node:20.5.1
npm:10.5.0
Java:1.8.0_351(如果存在多个版本Java,安装前将环境切换到jdk8)
安装
在终端输入命令
bash
npm install opentest -g
开始
新建终端,输入命令:
bash
cd ~
mkdir opentest
cd opentest
opentest quick-start
cd server
opentest server
再打开终端输入命令:
bash
cd opentest/actor1
opentest actor
然后使用浏览器访问http://localhost:3000,即可看到后台界面
脚本
Web
修改opentest/actor1/actor.yaml文件中selenium配置
需修改的地方:
XML
actorType:WEB
chromeDriverExePath: /opt/homebrew/bin/chromedriver
在opentest/test-repo/tests/web/目录新增需要测试的脚本,范例如下:
javascript
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配置
需修改的地方:
javascript
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/目录新增需要测试的脚本,范例如下:
javascript
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,然后选中对应脚本即可