我使用这个快速入门指南来安装这个测试框架:https ://github.com/codeception/codeceptjs/ 。
成功安装后,我编辑了“mytest_test.js”并添加了以下内容:
Feature('CodeceptJS Demonstration');
Scenario('test some forms', (I) => {
I.amOnPage('http://simple-form-bootstrap.plataformatec.com.br/documentation');
I.fillField('Email', 'hello@world.com');
I.fillField('Password', '123456');
I.checkOption('Active');
I.checkOption('Male');
I.click('Create User');
I.see('User is valid');
I.dontSeeInCurrentUrl('/documentation');
});
之后我开始了我的测试:
codeceptjs run --debug
我的结果是:
C:\laragon\www\codeceptjs2 (codeceptjs2@1.0.0) 31.01.2017 10:46:30,41
λ codeceptjs run --debug
CodeceptJS v0.4.16
Using test root "C:\laragon\www\codeceptjs2"
CodeceptJS Demonstration --
test some forms
> Error: Couldn't connect to selenium server
* I am on page "http://simple-form-bootstrap.plataformatec.com.br/documentation"
> Screenshot has been saved to C:\laragon\www\codeceptjs2\output\test_some_forms.failed.png
> Error: A session id is required for this command but wasn't found in the response payload
我在输出文件夹中没有任何屏幕截图,这个框架不起作用,我不明白为什么。
包.json
{
"name": "codeceptjs2",
"version": "1.0.0",
"description": "",
"main": "mytest_test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"codeceptjs": "^0.4.16",
"selenium-webdriver": "^3.0.1",
"webdriverio": "^4.6.2"
}
}
codecept.json
{
"tests": "./*_test.js",
"timeout": 10000,
"output": "./output",
"helpers": {
"WebDriverIO": {
"url": "http://localhost",
"browser": "firefox"
}
},
"include": {
"I": "./steps_file.js"
},
"bootstrap": false,
"mocha": {},
"name": "codeceptjs2"
}
steps_file.js
'use strict';
// in this file you can append custom step methods to 'I' object
module.exports = function() {
return actor({
// Define custom steps here, use 'this' to access default methods of I.
// It is recommended to place a general 'login' function here.
});
}