Capybara 的 Selenium 驱动程序不会单击 Jquery Mobile 按钮

发布于 2024-11-09 22:57:52 字数 2400 浏览 0 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

痕至 2024-11-16 22:57:52

尝试一下怎么样:

driver.ExecuteScript("$('#buttonName').click()");

这将适用于 Selenium 2 和 jQuery mobile。

How about trying:

driver.ExecuteScript("$('#buttonName').click()");

this will work with Selenium 2 and jQuery mobile.

染年凉城似染瑾 2024-11-16 22:57:52

当页面加载且处于非活动状态时(在 jQueryMobile 页面转换效果完成之前),Capybara 的 DOM 轮询可能会找到您的选择器。我通过按如下方式确定选择器的范围解决了这个问题:

before do
  click_link "get_ajax_page"
  should have_selector(".ui-page-active #my_id")
  click_link "link_on_ajax_page"
end

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:

before do
  click_link "get_ajax_page"
  should have_selector(".ui-page-active #my_id")
  click_link "link_on_ajax_page"
end

The have_selector will block the script until the page is active.

止于盛夏 2024-11-16 22:57:52

这听起来很熟悉,但我认为我们可能已经通过将 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文