[Checkins] SVN: gocept.selenium/trunk/src/gocept/selenium/ suppress 'null' window names as they are used synonymously with None/null by Selenium internally, added window-management tests
Thomas Lotze
tl at gocept.com
Wed Dec 7 15:28:44 UTC 2011
Log message for revision 123619:
suppress 'null' window names as they are used synonymously with None/null by Selenium internally, added window-management tests
Changed:
U gocept.selenium/trunk/src/gocept/selenium/selenese.py
U gocept.selenium/trunk/src/gocept/selenium/tests/test_selenese.py
-=-
Modified: gocept.selenium/trunk/src/gocept/selenium/selenese.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/selenese.py 2011-12-07 09:12:31 UTC (rev 123618)
+++ gocept.selenium/trunk/src/gocept/selenium/selenese.py 2011-12-07 15:28:44 UTC (rev 123619)
@@ -301,9 +301,11 @@
def mouseUpRightAt(self, locator, coord):
pass
- @passthrough
def openWindow(self, url, window_id):
- pass
+ if window_id == 'null':
+ raise ValueError("Cannot name a window 'null' "
+ "as this name is used be Selenium internally.")
+ return self.selenium.open_window(url, window_id)
def refresh(self):
# No thanks to selenium... why would one ever *not* want to wait for
@@ -420,9 +422,9 @@
pass
@assert_type('list')
- @passthrough
def getAllWindowNames(self):
- pass
+ return [name for name in self.selenium.get_all_window_names()
+ if name != 'null']
@assert_type('list')
@passthrough
Modified: gocept.selenium/trunk/src/gocept/selenium/tests/test_selenese.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/test_selenese.py 2011-12-07 09:12:31 UTC (rev 123618)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/test_selenese.py 2011-12-07 15:28:44 UTC (rev 123619)
@@ -262,3 +262,45 @@
self.selenium.verifyElementPresent, 'css=div#popup')
self.selenium.deselectPopUp()
self.selenium.verifyElementPresent('css=div#parent')
+
+
+class WindowManagementTest(HTMLTestCase):
+
+ def tearDown(self):
+ for name in self.selenium.getAllWindowNames():
+ if name == u'selenium_main_app_window':
+ continue
+ self.selenium.selectWindow('name=%s' % name)
+ self.selenium.close()
+ self.selenium.selectWindow(u'null')
+
+ def test_selenium_starts_out_with_one_window_listed(self):
+ self.selenium.assertAllWindowNames([u'selenium_main_app_window'])
+ self.selenium.assertEval('window.name', u'selenium_main_app_window')
+
+ def test_opening_new_window_adds_new_id(self):
+ self.selenium.openWindow('', 'foo')
+ self.selenium.assertAllWindowNames(
+ [u'selenium_main_app_window', u'foo'])
+
+ def test_newly_opened_window_needs_to_be_selected(self):
+ self.selenium.openWindow('', 'foo')
+ self.selenium.assertEval('window.name', u'selenium_main_app_window')
+ self.selenium.selectWindow('foo')
+ self.selenium.assertEval('window.name', u'foo')
+
+ def test_open_blank_window(self):
+ self.selenium.openWindow('', '_blank')
+ names = self.selenium.getAllWindowNames()
+ self.assertEqual(2, len(names))
+ self.assertEqual(u'selenium_main_app_window', names[0])
+ self.assertTrue(names[1].startswith('selenium_blank'))
+
+ def test_selecting_null_selects_main_window(self):
+ self.selenium.openWindow('', 'foo')
+ self.selenium.selectWindow('foo')
+ self.selenium.selectWindow(u'null')
+ self.selenium.assertEval('window.name', u'selenium_main_app_window')
+
+ def test_new_window_cannot_have_name_null(self):
+ self.assertRaises(ValueError, self.selenium.openWindow, '', 'null')
More information about the checkins
mailing list