Javascript casperjs测试内部站点

Javascript casperjs测试内部站点,javascript,phantomjs,casperjs,Javascript,Phantomjs,Casperjs,我正在尝试为内部站点运行casper测试。它在预生产环境中运行,目前的代码是 var casper = require('casper').create({ verbose: true, loglevel:"debug" }); // listening to a custom event casper.on('page.loaded', function() {

我正在尝试为内部站点运行casper测试。它在预生产环境中运行,目前的代码是

    var casper = require('casper').create({
                 verbose: true,
                 loglevel:"debug"
                 });

    // listening to a custom event
    casper.on('page.loaded', function() {
              this.echo('The page title is ' + this.getTitle());
              this.echo('value is: '+ this.getElementAttribute
                       ('input[id="edit-capture-amount"]', 
                        'value'));
    });

    casper.start('https://preprod.uk.systemtest.com', function() {
                 this.echo(this.getTitle());
                 this.capture('frontpage.png');
                 // emitting a custom event
                 this.emit('age.loaded.loaded');    
    });

    casper.run();
正如你所看到的,它不多,但我的问题是地址无法到达。捕获还显示一个空白页。不知道我做错了什么。我已经检查了cnn和谷歌网址的代码,标题和屏幕截图工作良好。不知道如何让它为内部站点工作

可以肯定

你能从casper运行的计算机上访问prepod.uk.systemtest.com吗?例如,使用ping或wget

您的计算机和Prepod服务器之间有代理吗?或者您的系统是否配置为通过不应用于Prepod服务器的代理

卡斯珀密码似乎没问题


我知道这应该是一条评论,但我没有足够的声誉发表评论。

我也有同样的问题。在我的浏览器中,我可以解析url,但capserjs无法解析。我得到的只是一个网页的
about::blank

添加
--ignore ssl errors=yes
非常有效

casperjs mytestjs //didn't work

capserjs --ignore-ssl-errors=yes mytestjs //worked perfect!

由于CasperJs测试在localhost中运行,为了测试自定义域/子域/主机,需要定义一些头

我在仅传递主机头时遇到了一些问题,例如,快照拍摄不正确

我又添加了2个标题,现在我的测试运行正常:

    casper.on('started', function () {
        var testHost = 'preprod.uk.systemtest.com';

        this.page.customHeaders = {
            'HOST': testHost,
            'HTTP_HOST': testHost,
            'SERVER_NAME': testHost
        };
    });

    var testing_url: 'http://localhost:8000/app_test.php';
    casper.start(_testing_url, function() {
    this.echo('I am using symfony, so this should have to show the homepage for the domain: preprod.uk.systemtest.com');
    this.echo('An the snapshot is also working');
    this.capture('casper_capture.png');
}

Prepod被锁得很紧,唯一有权访问该服务器的机器是运行该测试的工作站。机器位于同一网络内,因此没有任何代理。我不确定casper是否使用不同的ip地址访问web地址,因为如果使用,则需要在ngnix服务器中白名单上该地址。如果工作站与Prepod服务器位于同一网络上,则很容易猜测其ip地址。把Casper简单地看作一个普通的Web浏览器。你能用wget访问页面吗?它确实说它可以从我粘贴在输出中的wget连接UTC:\dev>wget.exe SYSTEM\u WGETRC=c:/progra~1/wget/etc/WGETRC syswgetrc=c:\Program Files(x86)\GnuWin32/etc/WGETRC--2013-03-06 17:18:58--解析prepod.uk.systemtest.com。。。100.300.30.210连接到prepod.uk.systemtest.com | 100.300.30.210 |:4403。。。connected.ERROR:无法验证prepod.uk.systemtest.com的证书,该证书由
/C=uk/ST=London/L=London/O=system]颁发:遇到自签名证书。错误:证书公用名
“与请求的主机名prepod.uk.systemtest.com”不匹配。要不安全地连接到prepod.uk.systemtest.com,请使用--无检查证书”。无法建立SSL连接。