我使用此快速入門指南來安裝此測試框架:https://github.com/codeception/codeceptjs/。codeceptjs - 錯誤:無法連接到硒服務器/該命令需要會話ID,但沒有在響應有效負載中找到
安裝成功後我修改了 「mytest_test.js」 具有以下補充:
Feature('CodeceptJS Demonstration');
Scenario('test some forms', (I) => {
I.amOnPage('http://simple-form-bootstrap.plataformatec.com.br/documentation');
I.fillField('Email', '[email protected]');
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 ([email protected]) 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
我沒有在輸出文件夾中得到任何截圖,這個框架不起作用,我不明白爲什麼。
的package.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.
});
}
我創建了一個新文件夾,並用'codeceptjs init'命令選擇了Nightmare。然後,我用'npm install --save-dev nightmare'安裝了惡夢。在我的package.json中:'「噩夢」:「^ 2.9.1」'。當我嘗試啓動我生成的測試文件時,立即得到一個Windows Script Host - 彈出式窗口,其中包含Microsoft JScript中的編譯錯誤。 –
我爲這個框架安裝了Firefox和Google驅動,現在一切正常。感謝與夢魘的提示。它在安裝以下內容後立即運行:'npm install -g nightmare nightmare-upload'。我會接受你的回答,並希望你能投票給我的問題。有人沒有理由投下它。 –