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