![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOtX5MGTKdT16yfMYLw4uj0o4Ml6b5BItol17YNvPQlK0l20ML8tASddcWKp1lufWkPfUrM2yM0UWci4SurirJ0jzSMOZL5ETE2pT7b2ua3_qjh9ZoLgcBFwiqIc5MbGHzcc64QjF1Oa0/s1600/capybara_cucumber_facebook_login_iframe.png)
main = page.driver.browser.window_handles.first
popup = page.driver.browser.window_handles.last
page.driver.browser.switch_to.window(popup)
Since iframe is a part of another source which is used to display another webpage in a webpage, you must handle it exactly same as pop-up windows.
page.driver.browser.switch_to.frame(iframe_name)
However, for iframe you must take the name of iframe to use it for assigning the webdriver. You can see the code below.
page.driver.browser.switch_to.frame(iframe_name)