casperjs - 使用casper.options并使用casper.tester专门注入casper clientScripts

alo*_*ser 4 casperjs

文档STRATE你可以传递一个options对象casperjs.create()包括JS clientScripts注入到客户端页面.

文件还规定,你不应该在一个测试文件casper.create实例.

文档没有说明(至少我找不到)如何使用optionscasper.tester类的对象.我确实尝试过这样的事情:

casper.options = {
    clientScripts:[
        '../testlib/sinon-1.7.3.js'
        ],
    logLevel:"warning",
    verbose:true

};  
Run Code Online (Sandbox Code Playgroud)

之前casper.test.begin但它打破了测试.

把它放在test.begin和casper.start之间.

casper.test.begin('Basic index.html elements test',14, function suite(test){
    casper.options..etc
    casper.start(url, function(){
    //also tried here
Run Code Online (Sandbox Code Playgroud)

而在它下面也打破了测试

我会为这方面的任何方向感到高兴.特别是注射部件

hex*_*xid 5

您需要将文件推入,casper.option.clientScripts以免破坏设置的其他选项casper test.

casper.options.clientScripts.push("../testlib/sinon-1.7.3.js");
Run Code Online (Sandbox Code Playgroud)

资料来源:CasperJS邮件列表