Capybara How to use within_frame for the only iframe in the page without id

守給你的承諾、 提交于 2019-12-25 02:28:19

问题


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?


回答1:


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



回答2:


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


来源:https://stackoverflow.com/questions/53227757/capybara-how-to-use-within-frame-for-the-only-iframe-in-the-page-without-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!