Bug 821303 - Added switch_to_default_content method to Marionette; r=dburns

This commit is contained in:
Jarek 'jarekps' Smiejczak 2013-09-10 15:18:00 +01:00
parent 73ade684d0
commit 8b8273a2f4
3 changed files with 18 additions and 1 deletions

View File

@ -816,6 +816,12 @@ class Marionette(object):
return HTMLElement(self, response)
return None
def switch_to_default_content(self):
'''
Switch the current context to page's default content.
'''
return self.switch_to_frame()
def switch_to_frame(self, frame=None, focus=True):
'''
Switch the current context to the specified frame. Subsequent commands will operate in the context of the specified frame, if applicable.

View File

@ -15,6 +15,7 @@ def switch_to_window_verify(test, start_url, frame, verify_title, verify_url):
test.assertEqual(test.marionette.get_active_frame(), None)
test.assertNotEqual("about:blank", test.marionette.execute_script("return window.location.href;"))
test.assertEqual(verify_title, test.marionette.title)
test.marionette.switch_to_default_content()
test.marionette.switch_to_frame(frame)
test.assertTrue(verify_url in test.marionette.get_url())
inner_frame_element = test.marionette.get_active_frame()
@ -66,3 +67,11 @@ class TestSwitchFrame(MarionetteTestCase):
self.marionette.find_element("id", "checkbox")
def testShouldAllowAUserToSwitchFromAnIframeBackToTheMainContentOfThePage(self):
test_iframe = self.marionette.absolute_url("test_iframe.html")
self.marionette.navigate(test_iframe)
self.marionette.switch_to_frame(0)
self.marionette.switch_to_default_content()
header = self.marionette.find_element("id", "iframe_page_heading")
self.assertEqual(header.text, "This is the heading")

View File

@ -8,6 +8,8 @@
<title>Marionette IFrame Test</title>
</head>
<body>
<iframe src="test.html" id="test_iframe"></iframe>
<h1 id="iframe_page_heading">This is the heading</h1>
<iframe src="test.html" id="test_iframe"></iframe>
</body>
</html>