使用 Selenium 和 WebDriver
通过 Spectron 配置
$ npm install --save-dev spectron// 一个简单的测试验证一个带标题的可见的窗口
var Application = require('spectron').Application
var assert = require('assert')
var app = new Application({
path: '/Applications/MyApp.app/Contents/MacOS/MyApp'
})
app.start().then(function () {
// 检查浏览器窗口是否可见
return app.browserWindow.isVisible()
}).then(function (isVisible) {
// 验证浏览器窗口是否可见
assert.equal(isVisible, true)
}).then(function () {
// 获得浏览器窗口的标题
return app.client.getTitle()
}).then(function (title) {
// 验证浏览器窗口的标题
assert.equal(title, 'My App')
}).catch(function (error) {
// 记录任何错误
console.error('Test failed', error.message)
}).then(function () {
// 停止应用程序
return app.stop()
})通过 WebDriverJs 配置
1. 启动 ChromeDriver
2. 安装 WebDriverJS
3. 联接到 ChromeDriver
通过 WebdriverIO 配置
1. 启动 ChromeDriver
2. 安装 WebdriverIO
3. 连接到 ChromeDriver
工作流程
Last updated