2012-12-04 59 views
0

我还没有找到一个明确的答案来查找和操纵我fancybox模式载入webapp中的元素。如何找到与水豚灯箱/ fancybox

within("div#fancybox-wrap.fancybox-desktop.fancybox-type-iframe.fancybox-opened") do 
    page.find_by_id('blah container').click 
end 

这里是一个更大的背景下所要求

<div class="fancybox-wrap fancybox-desktop fancybox-type-iframe fancybox-opened" style="width: 415px; height: auto; display: block; position: fixed; top: 20px; left: 467px; opacity: 1; overflow: visible;"> 
<div class="fancybox-skin" style="padding: 15px;"> 
    <div class="fancybox-outer"> 
     <div class="fancybox-inner" style="width: 385px; height: 229px; overflow: hidden;"> 
      <iframe class="fancybox-iframe" name="fancybox-frame" frameborder="0" hspace="0" scrolling="auto" src="index.php?module=Yadda&amp;action=[where I wan to be]&amp;popup=Y&amp;id=[unique]&amp;width=1010&amp;height=600"> 
       [the stuff I want to access] 
      </iframe> 
     </div> 
    </div> 
<div title="Close" class="fancybox-item fancybox-close"> 

这会产生以下拒绝......

Unable to find css "div#fancybox-wrap.fancybox-desktop.fancybox-type-iframe.fancybox-opened" (Capybara::ElementNotFound) 

请问有什么需要加/减?

+0

能否请您提供的的HTML页面或重现问题的页面? –

+0

增加更多信息 – TangibleDream

回答

1

css定位器不正确。

div#fancybox-wrap 

意味着ID “的fancybox缠绕” 一个div。基于html,“fancybox-wrap”是一个类。因此,你真正想要的(注意,“#”改为“”):

within("div.fancybox-wrap.fancybox-desktop.fancybox-type-iframe.fancybox-opened") do 
    page.find_by_id('blah container').click 
end 
+0

我认为那样做了。谢谢Justin! – TangibleDream

0

找到一个更好的答案,是由这个答案

Temporarily set js_errors to false in Poltergeist

的启发,但如果只会工作您正在使用幻灯片使用水豚的poltergist

# think about it. this is what you do in real life 
# Try to click thing you actually want. get caught by the the overlay then click to dismiss it away 
tried_before = false 
    if page.has_css?('#autostart') 
    begin 
     click_link "Insurance", match: :first 
    rescue Capybara::Poltergeist::MouseEventFailed 
     # close the fancy box 
     if tried_before 
     raise e 
     end 
     find('#fancybox-close').click 
     retry 
    end 
    end 
end 

它是做什么的?

  1. 尝试点击我们其实是想
  2. 的事情,如果它不能现在我们知道,罩面层的方式
  3. 我们可以单击它现在