Skip to content

Commit 4048477

Browse files
Clean up and reenable window switching tests
1 parent 290197a commit 4048477

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

py/test/selenium/webdriver/common/window_switching_tests.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
from selenium.common.exceptions import NoSuchWindowException
2121
from selenium.common.exceptions import WebDriverException
2222
from selenium.webdriver.common.by import By
23+
from selenium.webdriver.support import expected_conditions as EC
24+
from selenium.webdriver.support.ui import WebDriverWait
2325

2426

2527
class WindowSwitchingTests(unittest.TestCase):
2628

27-
@pytest.mark.ignore_marionette
2829
def testShouldSwitchFocusToANewWindowWhenItIsOpenedAndNotStopFutureOperations(self):
2930
self._loadPage("xhtmlTest")
3031
current = self.driver.current_window_handle
@@ -62,7 +63,10 @@ def testShouldThrowNoSuchWindowException(self):
6263
def testShouldThrowNoSuchWindowExceptionOnAnAttemptToGetItsHandle(self):
6364
self._loadPage("xhtmlTest")
6465
current = self.driver.current_window_handle
66+
handles = self.driver.window_handles
6567
self.driver.find_element(By.LINK_TEXT, "Open new window").click()
68+
69+
WebDriverWait(self.driver, 3).until(EC.new_window_is_opened(handles))
6670
handles = self.driver.window_handles
6771
handles.remove(current)
6872
self.driver.switch_to.window(handles[0])
@@ -78,12 +82,13 @@ def testShouldThrowNoSuchWindowExceptionOnAnAttemptToGetItsHandle(self):
7882

7983
@pytest.mark.ignore_chrome
8084
@pytest.mark.ignore_ie
81-
@pytest.mark.ignore_marionette
8285
def testShouldThrowNoSuchWindowExceptionOnAnyOperationIfAWindowIsClosed(self):
8386
self._loadPage("xhtmlTest")
8487
current = self.driver.current_window_handle
85-
88+
handles = self.driver.window_handles
8689
self.driver.find_element(By.LINK_TEXT, "Open new window").click()
90+
91+
WebDriverWait(self.driver, 3).until(EC.new_window_is_opened(handles))
8792
handles = self.driver.window_handles
8893
handles.remove(current)
8994
self.driver.switch_to.window(handles[0])
@@ -105,12 +110,13 @@ def testShouldThrowNoSuchWindowExceptionOnAnyOperationIfAWindowIsClosed(self):
105110

106111
@pytest.mark.ignore_chrome
107112
@pytest.mark.ignore_ie
108-
@pytest.mark.ignore_marionette
109113
def testShouldThrowNoSuchWindowExceptionOnAnyElementOperationIfAWindowIsClosed(self):
110114
self._loadPage("xhtmlTest")
111115
current = self.driver.current_window_handle
116+
handles = self.driver.window_handles
112117
self.driver.find_element(By.LINK_TEXT, "Open new window").click()
113118

119+
WebDriverWait(self.driver, 3).until(EC.new_window_is_opened(handles))
114120
handles = self.driver.window_handles
115121
handles.remove(current)
116122
self.driver.switch_to.window(handles[0])
@@ -130,10 +136,12 @@ def testClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToHang(self
130136
self._loadPage("xhtmlTest")
131137

132138
current = self.driver.current_window_handle
133-
139+
handles = self.driver.window_handles
134140
self.driver.find_element_by_name("windowThree").click()
135141

142+
WebDriverWait(self.driver, 3).until(EC.new_window_is_opened(handles))
136143
handles = self.driver.window_handles
144+
137145
handles.remove(current)
138146
self.driver.switch_to.window(handles[0])
139147

@@ -148,9 +156,10 @@ def testCanCallGetWindowHandlesAfterClosingAWindow(self):
148156
self._loadPage("xhtmlTest")
149157

150158
current = self.driver.current_window_handle
151-
159+
handles = self.driver.window_handles
152160
self.driver.find_element_by_name("windowThree").click()
153161

162+
WebDriverWait(self.driver, 3).until(EC.new_window_is_opened(handles))
154163
handles = self.driver.window_handles
155164
handles.remove(current)
156165
self.driver.switch_to.window(handles[0])
@@ -187,9 +196,10 @@ def testThatAccessingFindingAnElementAfterWindowIsClosedAndHaventswitchedDoesntC
187196
self._loadPage("xhtmlTest")
188197

189198
current = self.driver.current_window_handle
190-
199+
handles = self.driver.window_handles
191200
self.driver.find_element_by_name("windowThree").click()
192201

202+
WebDriverWait(self.driver, 3).until(EC.new_window_is_opened(handles))
193203
handles = self.driver.window_handles
194204
handles.remove(current)
195205
self.driver.switch_to.window(handles[0])

0 commit comments

Comments
 (0)