codeceptjs - Error: Couldn't connect to selenium server / A session id is required for this command but wasn't found in the response payload
codeceptjs - Error: Couldn't connect to selenium server / A session id is required for this command but wasn't found in the response payload
我使用这个快速入门指南来安装这个测试框架: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
我在输出文件夹中没有得到任何屏幕截图,这个框架不起作用,我不明白为什么。
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.
});
}
您确定它真的设置正确吗?我认为第一次测试后应该有一个确定和复选框。可能连google.com.
都没成功
如果这不是问题,也许您可以让它输出屏幕截图,或者使用 codecept 暂停功能并检查状态。
也有可能 google 将您的自动浏览器视为机器人,并没有发送我们看到的相同网页,因此它实际上发送了一个没有 #hplogo 元素的页面。
为了快速入门 CodeceptJs,我建议您使用 Nightmare 助手。
所以在 codecept.conf 你应该有类似的东西
'helpers': {
'Nightmare': {
'url': 'http://localhost:3000',
'waitForTimeout': 10000,
'show': false
}
},
并且不要忘记安装 nightmare
npm install --save-dev nightmare nightmare-upload
如果你使用 WebdriverIO 助手,你需要启动你的 selenium 服务器。
- npm 安装 selenium-standalone -g
- selnium-独立安装
- selenium-独立启动
之后你可以运行它
我使用这个快速入门指南来安装这个测试框架: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
我在输出文件夹中没有得到任何屏幕截图,这个框架不起作用,我不明白为什么。
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.
});
}
您确定它真的设置正确吗?我认为第一次测试后应该有一个确定和复选框。可能连google.com.
都没成功如果这不是问题,也许您可以让它输出屏幕截图,或者使用 codecept 暂停功能并检查状态。
也有可能 google 将您的自动浏览器视为机器人,并没有发送我们看到的相同网页,因此它实际上发送了一个没有 #hplogo 元素的页面。
为了快速入门 CodeceptJs,我建议您使用 Nightmare 助手。 所以在 codecept.conf 你应该有类似的东西
'helpers': {
'Nightmare': {
'url': 'http://localhost:3000',
'waitForTimeout': 10000,
'show': false
}
},
并且不要忘记安装 nightmare
npm install --save-dev nightmare nightmare-upload
如果你使用 WebdriverIO 助手,你需要启动你的 selenium 服务器。
- npm 安装 selenium-standalone -g
- selnium-独立安装
- selenium-独立启动
之后你可以运行它