Webkit无法找到iframe或其内容

Webkit无法找到iframe或其内容

本文介绍了Capybara:Webkit无法找到iframe或其内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我允许用户与其他人分享照片。当用户查看照片及其描述时,他们可以点击共享并加载新的页面。在此页面上填写电子邮件地址(以及可选注释 - 未在此处测试),然后点击共享照片。系统向收件人发送包含链接的电子邮件,主题行包括照片的名称。具有共享表单的页面还会显示该照片已与其共享的个人列表。

I allow users to share photos with other individuals. When the user is viewing a photo and its description, they can click on "share" and a new page loads. On this page the fill in an email address (and optional comments - not tested here) and click "Share Photo". The systems sends an email to the recipient with a link contained and the subject line includes the name of the photo. The page with the Share form also displays a list of individuals the photo has already been shared with.

全页加载是用户投诉的来源。他们想要一个模态窗口快速加载和最小化导航。我同意。

The full page load is a source of complaints from users. They want a modal window to quickly load and minimize navigation. I agree.

我使用 shadowbox.js 将共享页面加载到模式窗口中的iframe中。它工作得很好,并允许一个很好的后备到旧页面,如果需要。

I use shadowbox.js to load the Share page into an iframe in a modal window. It works well and allows a nice fallback to the old page if needed.

但是 - 我只是不能让我的测试通过。特别是,Capybara:Webkit只是找不到iframe。

But - I just can't get my tests to pass. In particular, Capybara:Webkit just can't find the iframe.

环境是:
Rail 3.0.9
capybara 0.4.1.2
capybara-webkit 0.5.0
cucumber 1.0.2

The environment is: Rail 3.0.9 capybara 0.4.1.2 capybara-webkit 0.5.0 cucumber 1.0.2

黄瓜故事:

Feature: Share photo

@javascript
Scenario: User shares photo
  When I follow "Share"
  Then I should see "Share Old Man Photo" inside "#sb-player"
  And I should see information about who I've shared this photo with
  When I fill in "Share with" with "[email protected]"
  And I press "Share Photo"
  Then "[email protected]" should receive an email with subject "Old Man photo has been shared with you"

我的步骤:

Then %r{^I should see "([^"]*)" inside ([^"].*)$} do |expected_text, named_element|
  selector = element_for(named_element)
  within_frame selector do
    page.should have_content(expected_text)
  end
end

失败消息:

(::) failed steps (::)

Unable to locate frame.  (Capybara::Driver::Webkit::WebkitError)
./features/step_definitions/sharing_steps.rb:94:in `/^I should see "([^"]*)" inside "([^"]*)"$/'
features/user_shares_photo.feature:21:in `Then I should see "Share Old Man Photo" inside "#sb-player"'

Failing Scenarios:
cucumber features/user_shares_photo.feature:19

。我只是不能得到Capybara:Webkit来识别iframe。

I've tried every combination of element ids. I just can't get Capybara:Webkit to recognize the iframe.

任何想法或解决方案?我不能交付失败的测试,并考虑投注整个iframe方法 - 但我想找到一个解决方案。

Any ideas or solutions? I can't deliver with failing test and am considering pitching the whole iframe approach - but I'd like to find a solution.

感谢

推荐答案

需要添加时间以允许iframe打开/填充。

Need to add time to allow the iframe to open/populate. Sleep 5 did it.

Then %r{^I should see "([^"]*)" inside ([^"].*)$} do |expected_text, named_element|
  sleep 5
  selector = element_for(named_element)
  within_frame selector do
    page.should have_content(expected_text)
  end
end

这篇关于Capybara:Webkit无法找到iframe或其内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 20:29