小编Sat*_*evg的帖子

CasperJS HTTP身份验证

不能简单地处理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);});
Run Code Online (Sandbox Code Playgroud)

我在控制台中看到的错误:

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.
Run Code Online (Sandbox Code Playgroud)

问:为什么我目前的Url与模式不匹配?谢谢.

testing phantomjs casperjs

4
推荐指数
1
解决办法
6243
查看次数

标签 统计

casperjs ×1

phantomjs ×1

testing ×1