Chromium Code Reviews| Index: chrome/test/pyautolib/pyauto.py |
| diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
| index ec3be84359210e4015a48fc641aff497e4c2b120..57d30cd476e72c8a42cb393b67eb271271fbf25d 100644 |
| --- a/chrome/test/pyautolib/pyauto.py |
| +++ b/chrome/test/pyautolib/pyauto.py |
| @@ -46,35 +46,17 @@ import types |
| import unittest |
| import urllib |
| +import pyauto_paths |
| + |
| def _LocateBinDirs(): |
| """Setup a few dirs where we expect to find dependency libraries.""" |
| - script_dir = os.path.dirname(__file__) |
| - chrome_src = os.path.join(script_dir, os.pardir, os.pardir, os.pardir) |
| - |
| - bin_dirs = { |
| - 'linux2': [ os.path.join(chrome_src, 'out', 'Debug'), |
| - os.path.join(chrome_src, 'sconsbuild', 'Debug'), |
| - os.path.join(chrome_src, 'out', 'Release'), |
| - os.path.join(chrome_src, 'sconsbuild', 'Release')], |
| - 'linux3': [ os.path.join(chrome_src, 'out', 'Debug'), |
| - os.path.join(chrome_src, 'sconsbuild', 'Debug'), |
| - os.path.join(chrome_src, 'out', 'Release'), |
| - os.path.join(chrome_src, 'sconsbuild', 'Release')], |
| - 'darwin': [ os.path.join(chrome_src, 'xcodebuild', 'Debug'), |
| - os.path.join(chrome_src, 'xcodebuild', 'Release')], |
| - 'win32': [ os.path.join(chrome_src, 'chrome', 'Debug'), |
| - os.path.join(chrome_src, 'build', 'Debug'), |
| - os.path.join(chrome_src, 'chrome', 'Release'), |
| - os.path.join(chrome_src, 'build', 'Release')], |
| - 'cygwin': [ os.path.join(chrome_src, 'chrome', 'Debug'), |
| - os.path.join(chrome_src, 'chrome', 'Release')], |
| - } |
| - deps_dirs = [ os.path.join(script_dir, os.pardir, |
| - os.pardir, os.pardir, 'third_party'), |
| - script_dir, |
| + deps_dirs = [ |
| + pyauto_paths.GetThirdPartyDir(), |
| + os.path.dirname(__file__), |
| + os.path.join(pyauto_paths.GetThirdPartyDir(), 'webdriver', 'python'), |
| ] |
| - sys.path += map(os.path.normpath, bin_dirs.get(sys.platform, []) + deps_dirs) |
| + sys.path += map(os.path.normpath, pyauto_paths.GetBuildDirs() + deps_dirs) |
| _LocateBinDirs() |
| @@ -104,7 +86,9 @@ from pyauto_errors import JSONInterfaceError |
| from pyauto_errors import NTPThumbnailNotShownError |
| import pyauto_utils |
| import simplejson as json # found in third_party |
| +from webdriver_factory import WebDriverFactory |
| +_WEBDRIVER_FACTORY = WebDriverFactory() |
| _HTTP_SERVER = None |
| _REMOTE_PROXY = None |
| _OPTIONS = None |
| @@ -2830,6 +2814,28 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
| } |
| return self._GetResultFromJSONRequest(cmd_dict) |
| + def NewWebDriver(self): |
| + """Returns a new remote WebDriver instance. |
| + |
| + Returns: |
| + selenium.webdriver.remote.webdriver.WebDriver instance |
| + """ |
| + global _WEBDRIVER_FACTORY |
| + return _WEBDRIVER_FACTORY.NewWebDriver(self) |
| + |
| + def CreateNewAutomationProvider(self, channel_id): |
| + """Creates a new automation provider. |
| + |
| + The provider will open a named channel in server mode. |
| + Args: |
| + channel_id: the channel_id to open the server channel with |
| + """ |
| + cmd_dict = { |
| + 'command': 'CreateNewAutomationProvider', |
| + 'channel_id': channel_id |
| + } |
| + self._GetResultFromJSONRequest(cmd_dict) |
| + |
| ## ChromeOS section |
| def GetLoginInfo(self): |
| @@ -3746,6 +3752,10 @@ class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite): |
| if _HTTP_SERVER: |
| self._StopHTTPServer() |
| + global _WEBDRIVER_FACTORY |
|
dtu
2011/07/29 21:57:31
nirnimesh: will we also need to add this to the Py
|
| + if _WEBDRIVER_FACTORY: |
| + _WEBDRIVER_FACTORY.Stop() |
| + |
| def _StartHTTPServer(self): |
| """Start a local file server hosting data files over http://""" |
| global _HTTP_SERVER |