【发布时间】:2015-09-01 08:10:22
【问题描述】:
我使用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();
});
});
...我用casperjs --ssl-protocol=any --ignore-ssl-errors=true test login.js 运行(一口)
我注定要失败吗?
【问题讨论】:
-
您确实应该将
casper.start()移动到casper.test.begin()内,否则当您添加另一个casper.test.begin()块时,您将遇到未定义的行为。
标签: javascript automation phantomjs casperjs