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

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

Issue 613163004: [chromedriver] setting browser default download directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/client/run_py_tests.py
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/client/run_py_tests.py
similarity index 98%
copy from chrome/test/chromedriver/test/run_py_tests.py
copy to chrome/test/chromedriver/client/run_py_tests.py
index 2b106a6783a372544520a9fcae0f182b673be9e2..7368bc5fc4eb77b9718ca9cfe7201927bd34365b 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/client/run_py_tests.py
@@ -140,7 +140,9 @@ _ANDROID_NEGATIVE_FILTER['chromedriver_webview_shell'] = (
class ChromeDriverBaseTest(unittest.TestCase):
"""Base class for testing chromedriver functionalities."""
-
+
+ download_dir = tempfile.mkdtemp(dir='/tmp')
samuong 2014/10/01 20:22:12 This is going to be used by all tests, which is no
andrewcheng 2014/10/08 22:08:26 def setUp(self): if self._testMethodName == 't
+
def __init__(self, *args, **kwargs):
super(ChromeDriverBaseTest, self).__init__(*args, **kwargs)
self._drivers = []
@@ -165,7 +167,7 @@ class ChromeDriverBaseTest(unittest.TestCase):
android_activity = constants.PACKAGE_INFO[_ANDROID_PACKAGE_KEY].activity
android_process = '%s:main' % android_package
- driver = chromedriver.ChromeDriver(server_url,
+ driver = chromedriver.ChromeDriver(server_url, self.download_dir,
chrome_binary=_CHROME_BINARY,
android_package=android_package,
android_activity=android_activity,
@@ -177,7 +179,7 @@ class ChromeDriverBaseTest(unittest.TestCase):
class ChromeDriverTest(ChromeDriverBaseTest):
"""End to end tests for ChromeDriver."""
-
+
@staticmethod
def GlobalSetUp():
ChromeDriverTest._http_server = webserver.WebServer(
@@ -208,6 +210,15 @@ class ChromeDriverTest(ChromeDriverBaseTest):
def testStartStop(self):
pass
+ def testFileDownLoad(self):
+ self._driver.Load(self.GetHttpUrlForFile('/chromedriver/download.html'))
samuong 2014/10/01 20:22:12 Before clicking, please also add a check that ensu
andrewcheng 2014/10/08 22:08:26 Done.
andrewcheng 2014/10/08 22:08:26 This is a random generated dir - very unlikely, a
+ self._driver.FindElement('id', 'red-dot').Click()
+ time.sleep(0.5)
samuong 2014/10/01 20:22:13 I'm a bit worried that this is going to be flaky,
andrewcheng 2014/10/08 22:08:26 download_name = ChromeDriverBaseTest.download_dir
+ download_name = ChromeDriverBaseTest.download_dir+"/a_red_dot.png";
samuong 2014/10/01 20:22:12 minor style nit: please put spaces around the + W
andrewcheng 2014/10/08 22:08:26 Done.
+ self.assertTrue(os.path.isfile(download_name), "Test user prefer download directory failed!")
samuong 2014/10/01 20:22:12 Another style nit: please keep lines within 80 cha
andrewcheng 2014/10/08 22:08:26 Done.
+ os.remove(download_name)
+ os.removedirs(ChromeDriverBaseTest.download_dir)
samuong 2014/10/01 20:22:12 If we add another test that uses the download dire
andrewcheng 2014/10/08 22:08:26 Done. def tearDown(self): try: if
+
def testLoadUrl(self):
self._driver.Load(self.GetHttpUrlForFile('/chromedriver/empty.html'))

Powered by Google App Engine
This is Rietveld 408576698