[Checkins] SVN: gocept.selenium/trunk/ API extension: added pop-up handling Selenese methods
Thomas Lotze
tl at gocept.com
Thu Mar 11 08:25:14 EST 2010
Log message for revision 109909:
API extension: added pop-up handling Selenese methods
Changed:
U gocept.selenium/trunk/CHANGES.txt
U gocept.selenium/trunk/src/gocept/selenium/selenese.py
U gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml
A gocept.selenium/trunk/src/gocept/selenium/tests/fixture/launch-popup.pt
A gocept.selenium/trunk/src/gocept/selenium/tests/fixture/popup.pt
U gocept.selenium/trunk/src/gocept/selenium/ztk/tests/test_selenese.py
-=-
Modified: gocept.selenium/trunk/CHANGES.txt
===================================================================
--- gocept.selenium/trunk/CHANGES.txt 2010-03-11 10:55:29 UTC (rev 109908)
+++ gocept.selenium/trunk/CHANGES.txt 2010-03-11 13:25:13 UTC (rev 109909)
@@ -4,9 +4,12 @@
0.3.1 (unreleased)
------------------
-- API expansion: add `getLocation` to retrieve currently loaded URL in
+- API expansion: add ``getLocation`` to retrieve currently loaded URL in
browser.
+- API expansion: added ``waitForPopUp``, ``selectPopUp``, ``deselectPopUp``
+ and ``close``.
+
- Usability: raise a better readable exception when an unimplemented selenese
method is called.
Modified: gocept.selenium/trunk/src/gocept/selenium/selenese.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/selenese.py 2010-03-11 10:55:29 UTC (rev 109908)
+++ gocept.selenium/trunk/src/gocept/selenium/selenese.py 2010-03-11 13:25:13 UTC (rev 109909)
@@ -67,7 +67,20 @@
def waitForPageToLoad(self):
self.selenium.wait_for_page_to_load(self.timeout * 1000)
+ def waitForPopUp(self, windowID):
+ self.selenium.wait_for_pop_up(windowID, self.timeout * 1000)
+
+ def selectPopUp(self, windowID, wait=True):
+ if wait:
+ self.waitForPopUp(windowID)
+ self.selenium.select_pop_up(windowID)
+
@passthrough
+ def close(self):
+ self.selenium.deselectPopUp()
+ pass
+
+ @passthrough
def createCookie(self, nameAndValue, options):
pass
@@ -76,6 +89,10 @@
pass
@passthrough
+ def deselectPopUp(self):
+ pass
+
+ @passthrough
def dragAndDropToObject(self, locatorSource, locatorDestination):
pass
Modified: gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml 2010-03-11 10:55:29 UTC (rev 109908)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/fixture/configure.zcml 2010-03-11 13:25:13 UTC (rev 109909)
@@ -24,4 +24,18 @@
permission="zope.Public"
/>
+ <browser:page
+ for="*"
+ name="launch-popup.html"
+ template="launch-popup.pt"
+ permission="zope.Public"
+ />
+
+ <browser:page
+ for="*"
+ name="popup.html"
+ template="popup.pt"
+ permission="zope.Public"
+ />
+
</configure>
Added: gocept.selenium/trunk/src/gocept/selenium/tests/fixture/launch-popup.pt
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/fixture/launch-popup.pt (rev 0)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/fixture/launch-popup.pt 2010-03-11 13:25:13 UTC (rev 109909)
@@ -0,0 +1,16 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+<head>
+<script type="text/javascript">
+function launch_popup() {
+ window.open('popup.html', 'gocept.selenium-popup');
+}
+</script>
+</head>
+
+<body onload="window.setTimeout(launch_popup, 1000)">
+<div id="parent">This is the parent window.</div>
+</body>
+</html>
Property changes on: gocept.selenium/trunk/src/gocept/selenium/tests/fixture/launch-popup.pt
___________________________________________________________________
Added: svn:keywords
+ Id Rev Date
Added: svn:eol-style
+ native
Added: gocept.selenium/trunk/src/gocept/selenium/tests/fixture/popup.pt
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/tests/fixture/popup.pt (rev 0)
+++ gocept.selenium/trunk/src/gocept/selenium/tests/fixture/popup.pt 2010-03-11 13:25:13 UTC (rev 109909)
@@ -0,0 +1,11 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
+<head>
+</head>
+
+<body>
+<div id="popup">This is a pop-up window.</div>
+</body>
+</html>
Property changes on: gocept.selenium/trunk/src/gocept/selenium/tests/fixture/popup.pt
___________________________________________________________________
Added: svn:keywords
+ Id Rev Date
Added: svn:eol-style
+ native
Modified: gocept.selenium/trunk/src/gocept/selenium/ztk/tests/test_selenese.py
===================================================================
--- gocept.selenium/trunk/src/gocept/selenium/ztk/tests/test_selenese.py 2010-03-11 10:55:29 UTC (rev 109908)
+++ gocept.selenium/trunk/src/gocept/selenium/ztk/tests/test_selenese.py 2010-03-11 13:25:13 UTC (rev 109909)
@@ -107,3 +107,43 @@
self.assertEquals(
'http://localhost:8087/',
self.selenium.getLocation())
+
+
+class PopUpTest(gocept.selenium.ztk.testing.TestCase):
+
+ def setUp(self):
+ super(PopUpTest, self).setUp()
+ self.selenium.open('/launch-popup.html')
+
+ def tearDown(self):
+ if self.selenium.getLocation().endswith('/popup.html'):
+ self.selenium.close()
+ self.selenium.deselectPopUp()
+ super(PopUpTest, self).tearDown()
+
+ def test_wait_for_popup(self):
+ self.selenium.waitForPopUp('gocept.selenium-popup')
+
+ def test_0_select_popup(self):
+ # XXX needs to be run first as pop-up windows can apparently be
+ # selected even after they have been closed.
+ self.assertRaises(Exception,
+ self.selenium.selectPopUp,
+ 'gocept.selenium-popup', wait=False)
+ self.selenium.selectPopUp('gocept.selenium-popup')
+ self.selenium.verifyElementPresent('css=div#popup')
+
+ def test_deselect_popup(self):
+ self.selenium.selectPopUp('gocept.selenium-popup')
+ self.selenium.deselectPopUp()
+ self.selenium.verifyElementNotPresent('css=div#popup')
+ self.selenium.verifyElementPresent('css=div#parent')
+
+ def test_close(self):
+ self.selenium.selectPopUp('gocept.selenium-popup')
+ self.selenium.verifyElementPresent('css=div#popup')
+ self.selenium.close()
+ self.assertRaises(Exception,
+ self.selenium.verifyElementPresent, 'css=div#popup')
+ self.selenium.deselectPopUp()
+ self.selenium.verifyElementPresent('css=div#parent')
More information about the checkins
mailing list