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

Side by Side Diff: tools/telemetry/telemetry/core/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: Address comments. 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 """Finds desktop browsers that can be controlled by telemetry."""
5
6 import os
7 import sys
8
9 from telemetry.core import browser
10 from telemetry.core import util
11 from telemetry.core import possible_browser
12 from telemetry.core.platform import util as platform_util
13 from telemetry.core.webdriver import webdriver_browser_backend
14
15
16 # Add webdriver selenium client to PYTHONPATH.
17 sys.path.insert(0, os.path.join(util.GetChromiumSrcDir(),
18 'third_party', 'webdriver', 'pylib'))
19 # TODO(chrisgao): Handle failure of import gracefully. crbug.com/266177
20 from selenium import webdriver # pylint: disable=F0401
21
22 ALL_BROWSER_TYPES = ','.join([
23 'internet-explorer',
24 'internet-explorer-x64'])
25
26
27 class PossibleWebDriverBrowser(possible_browser.PossibleBrowser):
28 """A browser that can be controlled through webdriver API."""
29
30 def __init__(self, browser_type, options):
31 super(PossibleWebDriverBrowser, self).__init__(browser_type, options)
32
33 def CreateWebDriverBackend(self):
34 raise NotImplementedError()
35
36 def Create(self):
37 backend = self.CreateWebDriverBackend()
38 b = browser.Browser(backend,
39 platform_util.CreatePlatformBackendForCurrentOS())
40 backend.SetBrowser(b)
41 return b
42
43 def SupportsOptions(self, options):
44 # TODO(chrisgao): Check if some options are not supported.
45 return True
46
47 @property
48 def last_modification_time(self):
49 return -1
50
51 def SelectDefaultBrowser(self, possible_browsers): # pylint: disable=W0613
52 return None
53
54
55 class PossibleDesktopIE(PossibleWebDriverBrowser):
56 def __init__(self, browser_type, options, architecture):
57 super(PossibleDesktopIE, self).__init__(browser_type, options)
58 self._architecture = architecture
59
60 def CreateWebDriverBackend(self):
61 # TODO(chrisgao): Check in IEDriverServer.exe and specify path to it when
62 # creating the webdriver instance. crbug.com/266170
63 driver = webdriver.Ie()
64 return webdriver_browser_backend.WebDriverBrowserBackend(
65 driver, False, self.options)
66
67
68 def FindAllAvailableBrowsers(options):
69 """Finds all the desktop browsers available on this machine."""
70 browsers = []
71
72 # Look for the IE browser in the standard location.
73 if sys.platform.startswith('win'):
74 ie_path = os.path.join('Internet Explorer', 'iexplore.exe')
75 win_search_paths = {
76 '32' : { 'path' : os.getenv('PROGRAMFILES(X86)'),
77 'type' : 'internet-explorer'},
78 '64' : { 'path' : os.getenv('PROGRAMFILES'),
79 'type' : 'internet-explorer-x64'}}
80 for architecture, ie_info in win_search_paths.iteritems():
81 if not ie_info['path']:
82 continue
83 if os.path.exists(os.path.join(ie_info['path'], ie_path)):
84 browsers.append(
85 PossibleDesktopIE(ie_info['type'], options, architecture))
86
87 return browsers
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698