CasperJS HTTP Auth

时间:2014-07-19 16:54:39

标签: casperjs http-basic-authentication

有没有办法使用CasperJS进行http身份验证?

我需要访问需要身份验证的屏幕,因此我的测试失败了,我无法访问这些表单的html。

1 个答案:

答案 0 :(得分:1)

您不需要访问html,只需调用CasperJS方法:

casper.test.begin('my test', 1, function suite(test) {

    var siteUrl = 'http://youwebsite.com.br'

    casper.start();
    casper.setHttpAuth('user', 'password');

    ...

我希望它可以帮到你