2013-01-01 66 views
1

我在Windows下評估CasperJS的測試API。不幸的是,Casper對象的測試屬性總是未定義的。爲什麼[對象Casper] .test未定義?

運行下面的腳本打印 「this.test未定義」:

phantom.casperPath = 'D:\\GitHubSources\\casperjs'; 
phantom.injectJs(phantom.casperPath + '\\bin\\bootstrap.js'); 

var casper = require('casper').create(); 

casper.start('http://localhost:56679/index.html', function(){ 
    this.echo('this.test is ' + this.test); 
}); 

casper.run(function(){ 
    this.exit(); 
}); 

任何提示?

回答

3

因爲您似乎使用1.1分支,它具有向後不兼容的變化;爲表示in the branch changelog

的卡斯帕對象將不與test參考創建如果使用casperjs test command沒有調用,因此不必呼叫摔落運行任何測試的能力。我知道,克服它。

PS:我其實考慮標記的master分支爲2.0

+0

NIKO,你說得對,我不小心用主分支。使用標籤1.0.0可以正常工作。感謝你傑出的工作! – paulroho