我有一些 CoffeeScript 文件,我正尝试在 Play 中使用 CasperJS 进行测试!带有 Java 的框架。几个不同的测试都失败了,我不知道为什么。第一种测试是处理click
事件。我们正在使用:
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
. 上述步骤之后的第二步是:
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
:
# 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
返回而不是预期值。我的 CoffeeScript 有任何错误吗?我是新手,所以我不能说我确定我做事正确。还是 Play!、CasperJS 和 CoffeeScript 之间的其他交互?