4
不能处理简单的HTTP认证。这里是我的代码:CasperJS HTTP认证
var x = require('casper').selectXPath;
var casper = require('casper').create({
verbose: false,
logLevel: 'debug'
});
casper.options.viewportSize = {width: 1366, height: 667};
casper.start('https://example.com/a/dashboard');
casper.setHttpAuth('username', 'password');
casper.then(function() {
this.test.assertUrlMatch(/^https:\/\/example.com\/a\/dashboard$/);
});
casper.run(function() {this.test.renderResults(true);});
和错误,我在控制台中看到:
casperjs mytest.js
FAIL Current url matches the provided pattern
# type: assertUrlMatch
# subject: false
# currentUrl: "https://example.com/login"
# pattern: "/^https:\\/\\/example.com\\/a\\/dashboard$/"
FAIL 1 tests executed in 2.428s, 0 passed, 1 failed.
问:为什么我当前的URL与简化版,模式匹配? 谢谢。
反正...不顺心的事。 CasperError:Casper未启动,无法执行'setHttpAuth()' /home/test:358 in checkStarted /home/test:1390 in setHttpAuth – Satevg
对不起,我编辑了我的答案以解决该问题。 – hexid