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

Unified Diff: chrome/test/pyautolib/pyauto.py

Issue 7523060: Let pyauto create an attached webdriver instance to manipulate web pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move bools into struct Created 9 years, 5 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/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__),
Nirnimesh 2011/08/01 19:21:24 this should go before third_party
kkania 2011/08/02 15:10:44 Done.
+ 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
Nirnimesh 2011/08/01 19:21:24 This would work if you have all the webdriver file
kkania 2011/08/02 15:10:44 Done.
+_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
+ if _WEBDRIVER_FACTORY:
+ _WEBDRIVER_FACTORY.Stop()
+
def _StartHTTPServer(self):
"""Start a local file server hosting data files over http://"""
global _HTTP_SERVER

Powered by Google App Engine
This is Rietveld 408576698