0

fancyboxのモーダルを搭載したWebアプリ内で要素を見つけて操作するための明確な答えが見つかりませんでした。

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)

足し算/引き算が必要なものはありますか?

4

2 に答える 2

1

cssロケーターが正しくありません。

持っている

div#fancybox-wrap

IDが「fancybox-wrap」のdivを意味します。htmlに基づくと、「fancybox-wrap」はクラスです。したがって、実際には必要です(「#」が「。」に変更されていることに注意してください)。

within("div.fancybox-wrap.fancybox-desktop.fancybox-type-iframe.fancybox-opened") do
    page.find_by_id('blah container').click
end
于 2012-12-04T18:54:14.567 に答える
0

この答えに触発されたより良い答えを見つけました

Poltergeistで一時的にjs_errorsをfalseに設定します

ただし、phantomjsでカピバラを使用している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. 今すぐクリックできます
于 2015-11-11T07:09:26.757 に答える