Capybara How to use within_frame for the only ifra

2019-08-28 02:26发布

I have an in the the page that I need to test with Cucumber and Capybara, the iframe does not have a class or id attribute but it's the only iframe on the DOM. How can I use the within_frame capybara method?

2条回答
男人必须洒脱
2楼-- · 2019-08-28 02:51

If you're using a recent version of Capybara the locator argument to within_frame is optional if there's only one iframe on the page

within_frame do
  # blah blah
end
查看更多
甜甜的少女心
3楼-- · 2019-08-28 03:03

use find to get the element and pass it to the within_frame method.

iframe = find('iframe')
within_frame(iframe) do
 # expect something here
end
查看更多
登录 后发表回答