我正在尝试点击我的Ember-CLI集成测试中的按钮,它可以与Chrome配合使用,但告诉我在PhantomJS中未定义点击。我已经看到一些其他帖子建议为PhantomJS定义你自己的点击事件,但我无法让它工作。
$("a:contains('Next'):visible")[0].click();
适用于Chrome,但不支持PhantomJS。在Ember-CLI中,内置的点击助手似乎无法使用“a:contains('Next'):visible”。
有人可以帮忙吗?
更新
我和Ember-CLI IRC上的一些人交谈,并让我的选择器在我的测试中使用Ember click helper,但现在点击似乎什么也没做。有什么想法吗?
test("Tour next, back, and cancel builtInButtons work", function(assert) {
assert.expect(6);
visit('/').then(function() {
assert.equal(find('.shepherd-active', 'html').length, 1, "Body gets class of shepherd-active, when shepherd becomes active");
assert.equal(find('.shepherd-enabled', 'body').length, 2, "attachTo element and tour get shepherd-enabled class");
assert.equal(find('#shepherdOverlay', 'body').length, 1, "#shepherdOverlay should exist, since isModal=true");
click('.next-button', '.shepherd-enabled');
andThen(function() {
assert.equal(find('.back-button', '.shepherd-enabled').length, 1, "Ensure that the back button appears");
});
click('.back-button', '.shepherd-enabled');
andThen(function() {
assert.equal(find('.back-button', '.shepherd-enabled').length, 0, "Ensure that the back button disappears");
});
click('.cancel-button', '.shepherd-enabled');
andThen(function() {
assert.equal(find('[class^=shepherd-button]', '.shepherd-enabled').length, 0, "Ensure that all buttons are gone, after exit");
});
});
});