Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: chrome/test/chromedriver/test.py

Issue 11746025: [chromedriver]Implement command: title. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/test.py
diff --git a/chrome/test/chromedriver/test.py b/chrome/test/chromedriver/test.py
index e8fe41dbaf3646e73ef892af9f8ff5963d849c47..dd939aa445b58d93bd1849712d1190be3ffbc88e 100644
--- a/chrome/test/chromedriver/test.py
+++ b/chrome/test/chromedriver/test.py
@@ -10,40 +10,60 @@ import sys
import unittest
import chromedriver
+import webserver
+
+_THIS_DIR = os.path.abspath(os.path.dirname(__file__))
+sys.path.insert(0, os.path.join(_THIS_DIR, os.pardir, 'pylib'))
+
+from common import chrome_paths
class ChromeDriverTest(unittest.TestCase):
"""End to end tests for ChromeDriver."""
+ @classmethod
+ def setUpClass(cls):
+ cls._http_server = webserver.WebServer(chrome_paths.GetTestData())
chrisgao (Use stgao instead) 2013/01/05 01:19:10 HTTP server is shared by all testcases.
+
+ @classmethod
+ def tearDownClass(cls):
+ cls._http_server.Shutdown()
+
+ @staticmethod
+ def GetHttpUrlForFile(file_path):
+ return ChromeDriverTest._http_server.GetUrl() + file_path
+
+ def setUp(self):
chrisgao (Use stgao instead) 2013/01/05 01:19:10 Add setUp and tearDown to ensure that chrome windo
+ self._driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
+
+ def tearDown(self):
+ self._driver.Quit()
+
def testStartStop(self):
- driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
- driver.Quit()
+ pass
def testLoadUrl(self):
- driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
- driver.Load('http://www.google.com')
- driver.Quit()
+ self._driver.Load(self.GetHttpUrlForFile('/chromedriver/empty.html'))
def testEvaluateScript(self):
- driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
- self.assertEquals(1, driver.ExecuteScript('return 1'))
- self.assertEquals(None, driver.ExecuteScript(''))
- driver.Quit()
+ self.assertEquals(1, self._driver.ExecuteScript('return 1'))
+ self.assertEquals(None, self._driver.ExecuteScript(''))
def testEvaluateScriptWithArgs(self):
- driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
script = ('document.body.innerHTML = "<div>b</div><div>c</div>";' +
'return {stuff: document.querySelectorAll("div")};')
- stuff = driver.ExecuteScript(script)['stuff']
+ stuff = self._driver.ExecuteScript(script)['stuff']
script = 'return arguments[0].innerHTML + arguments[1].innerHTML';
- self.assertEquals('bc', driver.ExecuteScript(script, stuff[0], stuff[1]))
- driver.Quit()
+ self.assertEquals(
+ 'bc', self._driver.ExecuteScript(script, stuff[0], stuff[1]))
def testEvaluateInvalidScript(self):
- driver = chromedriver.ChromeDriver(_CHROMEDRIVER_LIB, _CHROME_BINARY)
self.assertRaises(chromedriver.ChromeDriverException,
- driver.ExecuteScript, '{{{')
- driver.Quit()
+ self._driver.ExecuteScript, '{{{')
+
+ def testGetTitle(self):
+ self._driver.Load(self.GetHttpUrlForFile('/chromedriver/page_test.html'))
+ self.assertEqual('page test', self._driver.GetTitle())
chrisgao (Use stgao instead) 2013/01/05 01:19:10 As Load returns before the page is fully loaded, t
kkania 2013/01/08 21:26:29 We can't use load then until it waits for the navi
chrisgao (Use stgao instead) 2013/01/08 22:23:34 Done.
if __name__ == '__main__':

Powered by Google App Engine
This is Rietveld 408576698