【问题标题】:Internet Explorer as default browser for CasperJSInternet Explorer 作为 CasperJS 的默认浏览器
【发布时间】:2014-11-14 03:34:26
【问题描述】:

我有一个网站,每次部署后都需要对其进行测试。为了自动对应用程序进行烟雾测试,我想到了使用 casperjs。但困难在于它只能在顶级 IE 上运行。默认情况下,casperjs 仅在内置浏览器中支持 PhantomJS。 casperjs 是否存在类似于 DalekJS(dalek-browser-chrome) 或类似的插件?

下面附上完整的代码sn-p。

Casper 代码:

var LOGIN_URL, LOGIN_USERNAME, LOGIN_PASSWORD, casper;
var fs = require('fs');
casper = require('casper').create({
    waitTimeout: 20000,
    viewportSize: {
        width: 1024,
        height: 768
    },
    verbose: true,
    logLevel: 'debug'
});

if (!casper.cli.has('url') && !casper.cli.has('username') && !casper.cli.has('password')) {
    casper.echo('Usage: $ casperjs test.js --url=URL --username=USERNAME --password=PASSWORD').exit(-1);
}

LOGIN_URL = casper.cli.get('url');
LOGIN_USERNAME = casper.cli.get('username');
LOGIN_PASSWORD = casper.cli.get('password');

phantom.cookiesEnabled = true;

casper.start(LOGIN_URL, function () {
    this.log('Logging in', 'debug');
    this.fillSelectors('#login_form', {
        '#temp_username': LOGIN_USERNAME,
        '#temp_password': LOGIN_PASSWORD
    }, true);
})
.wait(20000,function(){
      fs.write("content.html",casper.getPageContent(), 'w');
})
.then(function(){
     this.click('#some-id');
})
.wait(20000,function(){
})   
.then(function(){
    this.capture("application.png");
    this.exit();
})
.run();

参考资料:

http://dalekjs.com/pages/getStarted.html

【问题讨论】:

    标签: javascript phantomjs casperjs dalekjs


    【解决方案1】:

    目前无法从 CasperJS 驱动 Internet Explorer。 TrifleJS 与 PhantomJS 具有相同的 API,但它没有集成到 CasperJS 中,也不知道它是否会。

    如果您真的想要多浏览器支持,您应该使用 为您选择的语言编写测试。

    供参考:
    IE support through TrifleJS?
    Remove spurious fs calls
    Add support to CasperJS

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-09
      • 1970-01-01
      • 1970-01-01
      • 2014-04-12
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 2015-08-17
      相关资源
      最近更新 更多