Capybara 的 Selenium 驱动程序不会单击 Jquery Mobile 按钮
Capybara 的 Selenium 驱动程序不会单击 JQuery Mobile 格式的按钮。它认为该按钮不可见。
有没有人看到这个问题并解决它?
我创建了一个“greenfield”应用程序,在这里演示这个问题: https://github.com/jevy/JQuery_Mobile_Capybara
@javascript
Scenario: Clicking a button doesn't complain # features/click_jq_mobile_button.feature:7
Given I am on the home page # features/step_definitions/web_steps.rb:44
Given I press "Some Button" # features/step_definitions/web_steps.rb:52
Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotDisplayedError)
[remote server] resource://fxdriver/modules/atoms.js:9442:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:256:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:305:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:320:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:197:in `unknown'
(eval):2:in `send'
(eval):2:in `click_button'
./features/step_definitions/web_steps.rb:53:in `/^(?:|I )press "([^"]*)"$/'
features/click_jq_mobile_button.feature:9:in `Given I press "Some Button"'
Failing Scenarios:
cucumber features/click_jq_mobile_button.feature:7 # Scenario: Clicking a button doesn't complain
Capybara's Selenium driver won't click on JQuery Mobile formatted buttons. It thinks the button is not visible.
Has anyone seen this issue and got around it?
I created a "greenfield" app demonstrating this issue here:
https://github.com/jevy/JQuery_Mobile_Capybara
@javascript
Scenario: Clicking a button doesn't complain # features/click_jq_mobile_button.feature:7
Given I am on the home page # features/step_definitions/web_steps.rb:44
Given I press "Some Button" # features/step_definitions/web_steps.rb:52
Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotDisplayedError)
[remote server] resource://fxdriver/modules/atoms.js:9442:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:256:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:305:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:320:in `unknown'
[remote server] file:///var/folders/fG/fGiEX6gLHQyvWGWb-5MpfU+++TI/-Tmp-/webdriver-profile20110525-21904-h3s00b/extensions/[email protected]/components/nsCommandProcessor.js:197:in `unknown'
(eval):2:in `send'
(eval):2:in `click_button'
./features/step_definitions/web_steps.rb:53:in `/^(?:|I )press "([^"]*)"$/'
features/click_jq_mobile_button.feature:9:in `Given I press "Some Button"'
Failing Scenarios:
cucumber features/click_jq_mobile_button.feature:7 # Scenario: Clicking a button doesn't complain
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试一下怎么样:
这将适用于 Selenium 2 和 jQuery mobile。
How about trying:
this will work with Selenium 2 and jQuery mobile.
当页面加载且处于非活动状态时(在 jQueryMobile 页面转换效果完成之前),Capybara 的 DOM 轮询可能会找到您的选择器。我通过按如下方式确定选择器的范围解决了这个问题:
have_selector
将阻止脚本,直到页面处于活动状态。Capybara's DOM polling might be finding your selector while the page is loaded and inactive (before the jQueryMobile page transition effect is complete). I solved this problem by scoping my selector as follows:
The
have_selector
will block the script until the page is active.这听起来很熟悉,但我认为我们可能已经通过将 Selenium 移至 capybara-webkit 来解决它:
http ://robots.thoughtbot.com/post/4583605733/capybara-webkit
This sounds familiar but I think we may have solved it by moving off Selenium to capybara-webkit:
http://robots.thoughtbot.com/post/4583605733/capybara-webkit