handling iframe with capybara ruby

2019-01-27 13:23发布

Below is the html code ..

<iframe id="I0_1366100881331" frameborder="0" width="100%">
<div class="ZRa">
<span id="button" class="hAa Qo Bg" tabindex="0" role="button" title="" aria-      label="Click here to publicly +1 this." aria-pressed="false">
</div>
</iframe>    

In the above scenario, I want to switch into the IFRAME (iframe id="I0_1366100881331") to perform some actions on the SPAN present in that IFRAME. I have tried with most of the cases but no result :(... any one please help.

I want the solution for cucumber using capybara ruby only..

Note: I tried with following code but no result.

page.driver.browser.switch_to.frame "I0_1366100881331"

标签: ruby capybara
3条回答
劫难
2楼-- · 2019-01-27 13:37
within_frame(find('<css rule>')) do
  <code for dealing with iframe entries>
end
查看更多
爷、活的狠高调
3楼-- · 2019-01-27 13:43

Can have this code:

withinframe((:xpath,"//div")) do
#code
end
查看更多
姐就是有狂的资本
4楼-- · 2019-01-27 13:44

I think you can try to use method:

within_frame 'id' do
  <code for dealing with iframe entries>
end
查看更多
登录 后发表回答