-
-
Save douglasmartins7/d0f48f66cf0c9bc27d3bebae5f8fc8e9 to your computer and use it in GitHub Desktop.
Capybara and Cucumber: Handling iframe, Pop-ups and Facebook Login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Facebook Login | |
As An anonymous user | |
I Want to login the webpage | |
So That I can buy anything | |
Background: Member should open home page | |
Given I go to home page | |
@javascript | |
Scenario: Member should be able to login with Facebook | |
When member login with Facebook | |
Then member should see popup window closes | |
And member see member informations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When(/^member login with Facebook$/) do | |
# set the main window | |
main = page.driver.browser.window_handles.first | |
# to enable to click Facebook login button we must switch to Facebook iframe | |
facebok_iframe_name = find(:xpath, "//*[@id='fb-button-explore']/span/iframe")[:name] | |
page.driver.browser.switch_to.frame facebok_iframe_name | |
# now we can click the Facebook login button which open the pop-up | |
find(:id, "u_0_1").click() | |
# to enable to fill the Facebook creditional set popup windows | |
# and then switch to popup window | |
popup = page.driver.browser.window_handles.last | |
page.driver.browser.switch_to.window(popup) | |
# fill form and click login button | |
fill_in("email", :with => "[email protected]") | |
fill_in("pass", :with => "Password123") | |
find(:id, "u_0_1").click() | |
# don't forget to switch to main window | |
page.driver.browser.switch_to.window(main) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment