如何在测试环境中的测试中设置 CasperJS 页面选项?
How to set CasperJS page options from within a test in test environment?
我 运行 我的大部分 CasperJS 测试都使用 test
命令以及
--ssl-protocol=any
和 --ignore-ssl-errors=true
标志。
如果它们在测试环境中,是否有办法将这 2 个标志添加到测试本身?我知道如果你使用像 var casper = require('casper').create({
这样的 casper 模块,你可以设置页面选项,但这不是我的测试设置方式。
我也知道你可以做
casper.options.verbose = true;
casper.options.logLevel = "debug";
...但是 casper.options.ignoreSslProtocol=true
似乎不起作用。
这是我的登录测试的一部分 --
var config = require('../../config'),
x = require('casper').selectXPath;
casper.test.comment('basic login test!');
casper.start(config.base_url);
casper.test.begin('test basic login functionality', function (test) {
casper.then(function() {
this.click('.js-flip_box');
test.info('logging in');
this.fill('#login_form', {
'email': config.email,
'password': config.password
}, true);
});
casper.then(function () {
test.assertVisible ('.home_bar', 'nav bar visible');
});
casper.run(function() {
test.done();
});
});
...which I 运行 with casperjs --ssl-protocol=any --ignore-ssl-errors=true test login.js
(a mouthful)
我注定要失败吗?
我 运行 我的大部分 CasperJS 测试都使用 test
命令以及
--ssl-protocol=any
和 --ignore-ssl-errors=true
标志。
如果它们在测试环境中,是否有办法将这 2 个标志添加到测试本身?我知道如果你使用像 var casper = require('casper').create({
这样的 casper 模块,你可以设置页面选项,但这不是我的测试设置方式。
我也知道你可以做
casper.options.verbose = true;
casper.options.logLevel = "debug";
...但是 casper.options.ignoreSslProtocol=true
似乎不起作用。
这是我的登录测试的一部分 --
var config = require('../../config'),
x = require('casper').selectXPath;
casper.test.comment('basic login test!');
casper.start(config.base_url);
casper.test.begin('test basic login functionality', function (test) {
casper.then(function() {
this.click('.js-flip_box');
test.info('logging in');
this.fill('#login_form', {
'email': config.email,
'password': config.password
}, true);
});
casper.then(function () {
test.assertVisible ('.home_bar', 'nav bar visible');
});
casper.run(function() {
test.done();
});
});
...which I 运行 with casperjs --ssl-protocol=any --ignore-ssl-errors=true test login.js
(a mouthful)
我注定要失败吗?