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

Unified Diff: tools/telemetry/telemetry/core/backends/webdriver/webdriver_desktop_browser_finder.py

Issue 20672002: [telemetry] Add a webdriver backend with support for IE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix errors after rebase. Created 7 years, 4 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: tools/telemetry/telemetry/core/backends/webdriver/webdriver_desktop_browser_finder.py
diff --git a/tools/telemetry/telemetry/core/backends/webdriver/webdriver_desktop_browser_finder.py b/tools/telemetry/telemetry/core/backends/webdriver/webdriver_desktop_browser_finder.py
new file mode 100644
index 0000000000000000000000000000000000000000..441c6f0c481b02ceb22c46485ef03e6dd764aa3c
--- /dev/null
+++ b/tools/telemetry/telemetry/core/backends/webdriver/webdriver_desktop_browser_finder.py
@@ -0,0 +1,86 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+"""Finds desktop browsers that can be controlled by telemetry."""
+
+import os
+import sys
+
+from telemetry.core import browser
+from telemetry.core import util
+from telemetry.core import possible_browser
+from telemetry.core import platform
+from telemetry.core.backends.webdriver import webdriver_browser_backend
+
+
+# Add webdriver selenium client to PYTHONPATH.
+sys.path.insert(0, os.path.join(util.GetChromiumSrcDir(),
+ 'third_party', 'webdriver', 'pylib'))
+# TODO(chrisgao): Handle failure of import gracefully. crbug.com/266177
+from selenium import webdriver # pylint: disable=F0401
+
+ALL_BROWSER_TYPES = ','.join([
+ 'internet-explorer',
+ 'internet-explorer-x64'])
+
+
+class PossibleWebDriverBrowser(possible_browser.PossibleBrowser):
+ """A browser that can be controlled through webdriver API."""
+
+ def __init__(self, browser_type, options):
+ super(PossibleWebDriverBrowser, self).__init__(browser_type, options)
+
+ def CreateWebDriverBackend(self):
+ raise NotImplementedError()
+
+ def Create(self):
+ backend = self.CreateWebDriverBackend()
+ b = browser.Browser(backend, platform.CreatePlatformBackendForCurrentOS())
+ return b
+
+ def SupportsOptions(self, options):
+ # TODO(chrisgao): Check if some options are not supported.
+ return True
+
+ @property
+ def last_modification_time(self):
+ return -1
+
+ def SelectDefaultBrowser(self, possible_browsers): # pylint: disable=W0613
+ return None
+
+
+class PossibleDesktopIE(PossibleWebDriverBrowser):
+ def __init__(self, browser_type, options, architecture):
+ super(PossibleDesktopIE, self).__init__(browser_type, options)
+ self._architecture = architecture
+
+ def CreateWebDriverBackend(self):
+ def DriverCreator():
+ # TODO(chrisgao): Check in IEDriverServer.exe and specify path to it when
+ # creating the webdriver instance. crbug.com/266170
+ return webdriver.Ie()
+ return webdriver_browser_backend.WebDriverBrowserBackend(
+ DriverCreator, False, self.options)
+
+
+def FindAllAvailableBrowsers(options):
+ """Finds all the desktop browsers available on this machine."""
+ browsers = []
+
+ # Look for the IE browser in the standard location.
+ if sys.platform.startswith('win'):
+ ie_path = os.path.join('Internet Explorer', 'iexplore.exe')
+ win_search_paths = {
+ '32' : { 'path' : os.getenv('PROGRAMFILES(X86)'),
+ 'type' : 'internet-explorer'},
+ '64' : { 'path' : os.getenv('PROGRAMFILES'),
+ 'type' : 'internet-explorer-x64'}}
+ for architecture, ie_info in win_search_paths.iteritems():
+ if not ie_info['path']:
+ continue
+ if os.path.exists(os.path.join(ie_info['path'], ie_path)):
+ browsers.append(
+ PossibleDesktopIE(ie_info['type'], options, architecture))
+
+ return browsers

Powered by Google App Engine
This is Rietveld 408576698