我已经通过Spectron工具使用Mocha为我的电子应用编写了一个登录测试用例。
我正面临以下问题。
你们能帮助我如何解决此问题,或者是否缺少所需的软件包。
我的package.json文件
{
"name": "new_spectron_module",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"dependencies": {
"npm": "^6.5.0",
"npm-check-updates": "^2.15.0",
"spectron": "^5.0.0"
},
"devDependencies": {
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.3",
"debug": "^4.1.0",
"electron": "^4.0.0",
"electroner": "^4.0.7",
"express": "^4.16.4",
"jade": "^1.11.0",
"mocha": "^5.2.0",
"morgan": "^1.9.1",
"serve-favicon": "^2.5.0",
"spectron-keys": "0.0.1",
"stylus": "^0.54.5",
"webdriverio": "^4.14.1"
},
"scripts": {
"test": "mocha"
},
"author": "",
"license": "ISC"
}
我的spec.js文件
var assert = require('assert');
var Application = require('spectron').Application
describe('Test Suite 1', function () {
this.timeout(500000)
beforeEach(function () {
this.app = new Application({
path: 'C:/Users/Admin/AppData/Local/Programs/Tradovate Trader Devel/Tradovate Trader Devel.exe'
})
return this.app.start()
})
/*afterEach(function () {
if (this.app && this.app.isRunning()) {
return this.app.stop()
}
})*/
it('Login', function () {
this.app.client.debug();
var txtUserName = this.app.client.element('//*[@id="content"]/div/div[2]/div/div[2]/div[1]/div[1]/div/input');
var txtPassword = this.app.client.element('//*[@id="content"]/div/div[2]/div/div[2]/div[1]/div[2]/div/input');
var btnSignIn = this.app.client.element('//*[@id="content"]/div/div[2]/div/div[2]/div[2]/div[1]/button');
//var accClick = this.app.client.element('//div[@class="pane account-selector dropdown"]//div[@class="caret"]');
//var logoutLink = this.app.client.element('//*[@id="content"]/div/div[1]/div[5]/div/ul/li[3]/a');
txtUserName.setValue('Clarion_19');
//thread.sleep(2000);
txtPassword.setValue('19Passw0rd$');
//click on signin button
btnSignIn.click();
//await accClick.click();
//logoutLink.click();
//console.log(btnSignIn.hasFocus());
})
})
答案 0 :(得分:0)
您是否尝试过先运行“ npm install”?