Chromium Code Reviews| Index: chrome/test/webdriver/chromedriver_tests.py |
| diff --git a/chrome/test/webdriver/chromedriver_tests.py b/chrome/test/webdriver/chromedriver_tests.py |
| index 94f15928e52866fc34e6044da3164ef9520670f3..c9e3fdecbfffb37df8bb384f5797f3bf7600b181 100755 |
| --- a/chrome/test/webdriver/chromedriver_tests.py |
| +++ b/chrome/test/webdriver/chromedriver_tests.py |
| @@ -14,6 +14,7 @@ import hashlib |
| import os |
| import platform |
| import sys |
| +import tempfile |
| import unittest |
| import urllib |
| import urllib2 |
| @@ -290,7 +291,7 @@ class CookieTest(unittest.TestCase): |
| cookie_dict = None |
| cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") |
| cookie_dict = {} |
| - cookie_dict["name"]= "chromedriver_cookie_test" |
| + cookie_dict["name"] = "chromedriver_cookie_test" |
| cookie_dict["value"] = "this is a test" |
| self._driver.add_cookie(cookie_dict) |
| cookie_dict = self._driver.get_cookie("chromedriver_cookie_test") |
| @@ -596,6 +597,49 @@ class AutofillTest(unittest.TestCase): |
| 'Saved CC line item not same as what was entered.') |
| +class FileUploadControlTest(unittest.TestCase): |
| + """Tests dealing with file upload control.""" |
| + |
| + def setUp(self): |
| + self._launcher = ChromeDriverLauncher(root_path=os.path.dirname(__file__)) |
| + self._driver = WebDriver(self._launcher.GetURL(), |
| + DesiredCapabilities.CHROME) |
| + |
| + def tearDown(self): |
| + self._driver.quit() |
| + self._launcher.Kill() |
| + |
| + def testSetFilePathToFileUploadControl(self): |
| + """Verify a file path is set to the file upload control.""" |
| + self._driver.get(self._launcher.GetURL() + '/upload.html') |
| + |
| + file = tempfile.NamedTemporaryFile() |
| + |
| + fileupload = self._driver.find_element_by_name('fileupload') |
| + fileupload.send_keys(file.name) |
| + path = fileupload.value |
| + self.assertTrue(path.endswith(os.path.basename(file.name))) |
|
kkania
2011/06/07 15:12:04
do you need to close/delete the temp file?
nodchip
2011/06/08 02:37:19
I think we don't need to manually close/delete the
|
| + |
| + def testSetMultipleFilePathsToFileUploadControl(self): |
| + """Verify multiple file paths are set to the file upload control.""" |
| + self._driver.get(self._launcher.GetURL() + '/upload.html') |
| + |
| + files = list() |
| + filepaths = list() |
| + filenames = set() |
| + for index in xrange(4): |
| + file = tempfile.NamedTemporaryFile() |
| + files.append(file) |
| + filepath = file.name |
| + filepaths.append(filepath) |
| + filenames.add(os.path.basename(filepath)) |
| + |
| + fileupload = self._driver.find_element_by_name('fileupload') |
| + fileupload.send_keys(filepaths[0], filepaths[1], filepaths[2], filepaths[3]) |
| + path = fileupload.value.replace('\\', '//') |
| + self.assertTrue(os.path.basename(path) in filenames) |
| + |
| + |
| if __name__ == '__main__': |
| unittest.main(module='chromedriver_tests', |
| testRunner=GTestTextTestRunner(verbosity=1)) |