我正在使用 CasperJS 1.1,我想模拟单击文件字段,但是在运行测试时出现错误(该项目使用 AngularJS fwiw):
# Create gallery page
PASS File field exists
FAIL Cannot dispatch mousedown event on nonexistent selector: input#gallery_file_0
# type: uncaughtError
# file: spec/javascripts/casperjs/create_gallery.coffee:1323
# error: Cannot dispatch mousedown event on nonexistent selector: input#gallery_file_0
# CasperError: Cannot dispatch mousedown event on nonexistent selector: input#gallery_file_0
# at mouseEvent (/usr/local/Cellar/casperjs/1/libexec/modules/casper.js:1323)
# at click (/usr/local/Cellar/casperjs/1/libexec/modules/casper.js:428)
# at spec/javascripts/casperjs/create_gallery.coffee:7
# at runStep (/usr/local/Cellar/casperjs/1/libexec/modules/casper.js:1523)
# at checkStep (/usr/local/Cellar/casperjs/1/libexec/modules/casper.js:368)
# stack: not provided
这个错误对我来说没有意义,因为我之前关于输入字段存在的断言实际上是正确的。这是测试文件:
casper.test.begin "Create gallery page", 1, (test) ->
casper.start "http://localhost:3000/galleries/new", ->
@then ->
test.assertField("input#gallery_file_0", null, "File field exists")
@click("input#gallery_file_0")
casper.run()
可能是什么问题?
版本:
casperjs --version
1.1.0-DEV
phantomjs -v
1.9.1
MacOSX 10.8.4