Created
June 20, 2016 21:53
-
-
Save abstatic/f59103256e6f04c8cef37508efbd82d0 to your computer and use it in GitHub Desktop.
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
def login(self, driver): | |
""" | |
This method is internal to testing framework | |
It is used to login the user. | |
Each test requires the user to be logged in already | |
Parameters: | |
driver - reference to driver being used | |
""" | |
# this is the tricky part | |
# We have to get the right handle for the correct popup login window | |
main_window_handle = driver.current_window_handle | |
driver.find_element_by_id('signin').click() | |
signin_window_handle = None | |
# iterating through all the handles to get the popup, since we only hve | |
# one popup, making use of that | |
while not signin_window_handle: | |
for handle in driver.window_handles: | |
if handle != main_window_handle: | |
signin_window_handle = handle | |
break | |
# switch to the signin popup | |
driver.switch_to.window(signin_window_handle) | |
wait = WebDriverWait(driver, 60) | |
email_field = wait.until( | |
EC.element_to_be_clickable((By.ID, "authentication_email"))) | |
# this is the example user from mockmyid | |
email_field.send_keys("[email protected]") | |
# xpath id obtained using firebug for the next button on persona dialog | |
(driver.find_element_by_xpath( | |
"/html/body/div/section[1]/form/div[2]/div[1]/div/div[2]/p[4]/button[1]") | |
.click()) | |
# switch to the main window | |
driver.switch_to.window(main_window_handle) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment