Permalink
Browse files

Merge pull request #8 from zacc/use_window_handles

Switch back to the main window by using the window handle.
  • Loading branch information...
2 parents d841394 + 35db833 commit 29318f848e26cef2558ceb5763fb3625e814c13d @davehunt davehunt committed May 21, 2012
Showing with 6 additions and 1 deletion.
  1. +5 −0 pages/webdriver/base.py
  2. +1 −1 pages/webdriver/sign_in.py
@@ -12,8 +12,13 @@ class Base(object):
def __init__(self, selenium, timeout=60):
self.selenium = selenium
self.timeout = timeout
+ self._main_window_handle = self.selenium.current_window_handle
+
if selenium.title != self._page_title:
for handle in selenium.window_handles:
selenium.switch_to_window(handle)
if selenium.title == self._page_title:
break
+
+ def switch_to_main_window(self):
+ self.selenium.switch_to_window(self._main_window_handle)
@@ -55,7 +55,7 @@ def click_next(self):
def click_sign_in(self):
"""Clicks the 'Sign In' button."""
self.selenium.find_element(*self._sign_in_locator).click()
- self.selenium.switch_to_window('')
+ self.switch_to_main_window()
def sign_in(self, email, password):
"""Signs in using the specified email address and password."""

0 comments on commit 29318f8

Please sign in to comment.