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

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: 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 possible_browser
11 from telemetry.core.platform import win_platform_backend
12 from telemetry.core.webdriver import webdriver_browser_backend
13
14
15 # Add webdriver selenium client to PYTHONPATH.
16 sys.path.insert(0, os.path.join(os.path.dirname(__file__),
17 '..', '..', '..', '..', '..', 'third_party',
tonyg 2013/07/26 18:21:07 util.GetChromiumSrcDir()
chrisgao (Use stgao instead) 2013/07/30 02:06:49 Thx, this makes it easier and cleaner.
18 'webdriver', 'pylib'))
19 from selenium import webdriver # pylint: disable=F0401
20
21 ALL_BROWSER_TYPES = ','.join([
22 'webdriver.ie32',
tonyg 2013/07/26 18:21:07 Since these are user-facing names, can we call the
chrisgao (Use stgao instead) 2013/07/30 02:06:49 Done.
23 'webdriver.ie64'])
24
25
26 class PossibleIEDesktopBrowser(possible_browser.PossibleBrowser):
tonyg 2013/07/26 18:21:07 Should this really be called PossibleIE or just Po
chrisgao (Use stgao instead) 2013/07/30 02:06:49 I don't think firefox can share the same class, as
27 """A desktop browser that can be controlled."""
28
29 def __init__(self, browser_type, options, bit):
30 super(PossibleIEDesktopBrowser, self).__init__(browser_type, options)
31 self._bit = bit
32
33 def __repr__(self):
34 return 'PossibleIEDesktopBrowser(browser_type=%s)' % self.browser_type
35
36 def Create(self):
37 # TODO Currently require that IEDriver.exe is in PATH.
chrisgao (Use stgao instead) 2013/07/26 16:58:00 IEDriver.exe -> IEDriverServer.exe
tonyg 2013/07/26 18:21:07 Can we check for this and display a user-friendly
chrisgao (Use stgao instead) 2013/07/30 02:06:49 Done.
chrisgao (Use stgao instead) 2013/07/30 02:06:49 We can delegate this to the underlying IE Driver a
38 driver = webdriver.Ie()
39 backend = webdriver_browser_backend.WebDriverBrowserBackend(
40 driver, False, self._options)
41 b = browser.Browser(backend, win_platform_backend.WinPlatformBackend())
42 backend.SetBrowser(b)
43 return b
44
45 def SupportsOptions(self, options):
46 return True
47
48
49 def FindAllAvailableBrowsers(options):
50 """Finds all the desktop browsers available on this machine."""
51 browsers = []
52
53 # Look for the IE browser in the standard location.
54 if sys.platform.startswith('win'):
55 ie_path = os.path.join('Internet Explorer', 'iexplore.exe')
56 win_search_paths = {'32' : os.getenv('PROGRAMFILES(X86)'),
57 '64' : os.getenv('PROGRAMFILES')}
chrisgao (Use stgao instead) 2013/07/26 16:58:00 According to https://code.google.com/p/selenium/wi
tonyg 2013/07/26 18:21:07 There is also code in desktop_browser_finder.py th
chrisgao (Use stgao instead) 2013/07/30 02:06:49 I'm afraid we can't share much of the code, becaus
58
59 for bit, path in win_search_paths.iteritems():
tonyg 2013/07/26 18:21:07 s/bit/architecture/
chrisgao (Use stgao instead) 2013/07/30 02:06:49 Done.
60 if not path:
61 continue
62 if os.path.exists(os.path.join(path, ie_path)):
63 browsers.append(
64 PossibleIEDesktopBrowser('webdriver.ie%s' % bit, options, bit))
65
66 return browsers
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698