0
我有一些CoffeeScript文件,我試圖用CasperJS在Play中測試!框架瓦特/ Java。幾個不同的測試失敗,我無法弄清楚爲什麼。第一種測試是處理click
事件。我們使用:CasperJS在點擊事件和assertEquals與CoffeeScript失敗
casper.start(casper.uri("/starting/url"))
casper.then ->
casper.click "#start-hsa-app-button"
這給我的錯誤:
CasperError: Cannot dispatch click event on nonexistent selector: #start-hsa-app-button
與id
#start-hsa-app-button
的聯繫肯定是存在的。
第二個錯誤是使用assertEquals
。以上步驟之後,第二個步驟是:所以
# US/non-US address switching
FAIL #address3 not visible
# type: assertEquals
# subject: null
# expected: false
FAIL #city visible
# type: assertEquals
# subject: null
# expected: true
FAIL #state visible
# type: assertEquals
# subject: null
# expected: true
FAIL #zip visible
# type: assertEquals
# subject: null
# expected: true
# click #nonUsAddress on
FAIL #coverageType_I not checked
# type: assertEquals
# subject: null
# expected: false
FAIL #coverageGroupName not visible
# type: assertEquals
# subject: null
# expected: false
FAIL #coverageGroupNumber not visible
# type: assertEquals
# subject: null
# expected: false
對我來說似乎是asserts
越來越null
返回,而不是預期值:
casper.then ->
@test.comment "US/non-US address switching"
@assertNotVisible "#address3"
@assertVisible "#city"
@assertVisible "#state"
@assertVisible "#zip"
@test.comment "click #nonUsAddress on"
@click "#nonUsAddress"
@assertVisible "#address3"
@assertNotVisible "#city"
@assertNotVisible "#state"
@assertNotVisible "#zip"
@test.comment "click #nonUsAddress off"
@click "#nonUsAddress"
它返回null
所有斷言。我的CoffeeScript有任何錯誤嗎?我新使用它,所以我不能說我確定我正在做的事情。或者是Play!,CasperJS和CoffeeScript之間的其他互動?
CasperJS中的詳細模式可能有助於發現問題。請參閱http://casperjs.org/debugging.html – theMike