Skip to content

Commit

Permalink
Updating window switching tests for what works with Marionette
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Jan 28, 2016
1 parent 55d1271 commit 069eb4e
Showing 1 changed file with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions py/test/selenium/webdriver/common/window_switching_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ def testShouldSwitchFocusToANewWindowWhenItIsOpenedAndNotStopFutureOperations(se

self.driver.find_element_by_link_text("Open new window").click()
self.assertEqual(self.driver.title, "XHTML Test Page")

self.driver.switch_to.window("result")
handles = self.driver.window_handles
handles.remove(current)
self.driver.switch_to.window(handles[0])
self.assertEqual(self.driver.title, "We Arrive Here")

self._loadPage("iframes")
handle = self.driver.current_window_handle
self.driver.find_element_by_id("iframe_page_heading")
self.driver.switch_to.frame("iframe1")
self.driver.switch_to.frame(self.driver.find_element(By.ID, "iframe1"))

self.assertEqual(self.driver.current_window_handle, handle)

Expand All @@ -56,12 +57,14 @@ def testShouldThrowNoSuchWindowException(self):
self.driver.switch_to.window(current)

@pytest.mark.ignore_chrome
@pytest.mark.ignore_marionette
def testShouldThrowNoSuchWindowExceptionOnAnAttemptToGetItsHandle(self):
self._loadPage("xhtmlTest")
current = self.driver.current_window_handle
self.driver.find_element(By.LINK_TEXT,"Open new window").click()

self.driver.switch_to.window("result")
handles = self.driver.window_handles
handles.remove(current)
self.driver.switch_to.window(handles[0])
self.driver.close()

try :
Expand All @@ -74,13 +77,15 @@ def testShouldThrowNoSuchWindowExceptionOnAnAttemptToGetItsHandle(self):

@pytest.mark.ignore_chrome
@pytest.mark.ignore_ie
@pytest.mark.ignore_marionette
def testShouldThrowNoSuchWindowExceptionOnAnyOperationIfAWindowIsClosed(self):
self._loadPage("xhtmlTest")
current = self.driver.current_window_handle

self.driver.find_element(By.LINK_TEXT,"Open new window").click()

self.driver.switch_to.window("result")
handles = self.driver.window_handles
handles.remove(current)
self.driver.switch_to.window(handles[0])
self.driver.close()
try:
try :
Expand All @@ -99,12 +104,15 @@ def testShouldThrowNoSuchWindowExceptionOnAnyOperationIfAWindowIsClosed(self):

@pytest.mark.ignore_chrome
@pytest.mark.ignore_ie
@pytest.mark.ignore_marionette
def testShouldThrowNoSuchWindowExceptionOnAnyElementOperationIfAWindowIsClosed(self):
self._loadPage("xhtmlTest")
current = self.driver.current_window_handle
self.driver.find_element(By.LINK_TEXT,"Open new window").click()

self.driver.switch_to.window("result")
handles = self.driver.window_handles
handles.remove(current)
self.driver.switch_to.window(handles[0])
element = self.driver.find_element_by_tag_name("body")
self.driver.close()

Expand All @@ -116,37 +124,43 @@ def testShouldThrowNoSuchWindowExceptionOnAnyElementOperationIfAWindowIsClosed(s
finally:
self.driver.switch_to.window(current)

@pytest.mark.ignore_marionette
def testClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToHang(self):
self._loadPage("xhtmlTest")

currentHandle = self.driver.current_window_handle
current = self.driver.current_window_handle

self.driver.find_element_by_name("windowThree").click()

self.driver.switch_to.window("result")
handles = self.driver.window_handles
handles.remove(current)
self.driver.switch_to.window(handles[0])

try:
self.driver.find_element_by_id("close").click()
finally:
self.driver.switch_to.window(currentHandle)
self.driver.switch_to.window(current)
self.driver.find_element_by_id("linkId")

@pytest.mark.ignore_marionette
def testCanCallGetWindowHandlesAfterClosingAWindow(self):
self._loadPage("xhtmlTest")

currentHandle = self.driver.current_window_handle
current = self.driver.current_window_handle

self.driver.find_element_by_name("windowThree").click()

self.driver.switch_to.window("result")
handles = self.driver.window_handles
handles.remove(current)
self.driver.switch_to.window(handles[0])

try:
self.driver.find_element_by_id("close").click()
all_handles = self.driver.window_handles

self.assertEqual(1, len(all_handles))
finally:
self.driver.switch_to.window(currentHandle)
self.driver.switch_to.window(current)

def testCanObtainAWindowHandle(self):
self._loadPage("xhtmlTest")
Expand All @@ -167,14 +181,17 @@ def testFailingToSwitchToAWindowLeavesTheCurrentWindowAsIs(self):

self.assertEqual(current, new_handle)

@pytest.mark.ignore_marionette
def testThatAccessingFindingAnElementAfterWindowIsClosedAndHaventswitchedDoesntCrash(self):
self._loadPage("xhtmlTest")

currentHandle = self.driver.current_window_handle
current = self.driver.current_window_handle

self.driver.find_element_by_name("windowThree").click()

self.driver.switch_to.window("result")
handles = self.driver.window_handles
handles.remove(current)
self.driver.switch_to.window(handles[0])

try:
self.driver.find_element_by_id("close").click()
Expand Down

0 comments on commit 069eb4e

Please sign in to comment.