Chromium Code Reviews| Index: tools/telemetry/telemetry/core/webdriver/webdriver_desktop_browser_finder.py |
| diff --git a/tools/telemetry/telemetry/core/webdriver/webdriver_desktop_browser_finder.py b/tools/telemetry/telemetry/core/webdriver/webdriver_desktop_browser_finder.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9e1ffffc571fba761479ced04fc8cc93baf3f8af |
| --- /dev/null |
| +++ b/tools/telemetry/telemetry/core/webdriver/webdriver_desktop_browser_finder.py |
| @@ -0,0 +1,66 @@ |
| +# 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 possible_browser |
| +from telemetry.core.platform import win_platform_backend |
| +from telemetry.core.webdriver import webdriver_browser_backend |
| + |
| + |
| +# Add webdriver selenium client to PYTHONPATH. |
| +sys.path.insert(0, os.path.join(os.path.dirname(__file__), |
| + '..', '..', '..', '..', '..', '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.
|
| + 'webdriver', 'pylib')) |
| +from selenium import webdriver # pylint: disable=F0401 |
| + |
| +ALL_BROWSER_TYPES = ','.join([ |
| + '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.
|
| + 'webdriver.ie64']) |
| + |
| + |
| +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
|
| + """A desktop browser that can be controlled.""" |
| + |
| + def __init__(self, browser_type, options, bit): |
| + super(PossibleIEDesktopBrowser, self).__init__(browser_type, options) |
| + self._bit = bit |
| + |
| + def __repr__(self): |
| + return 'PossibleIEDesktopBrowser(browser_type=%s)' % self.browser_type |
| + |
| + def Create(self): |
| + # 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
|
| + driver = webdriver.Ie() |
| + backend = webdriver_browser_backend.WebDriverBrowserBackend( |
| + driver, False, self._options) |
| + b = browser.Browser(backend, win_platform_backend.WinPlatformBackend()) |
| + backend.SetBrowser(b) |
| + return b |
| + |
| + def SupportsOptions(self, options): |
| + return True |
| + |
| + |
| +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' : os.getenv('PROGRAMFILES(X86)'), |
| + '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
|
| + |
| + 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.
|
| + if not path: |
| + continue |
| + if os.path.exists(os.path.join(path, ie_path)): |
| + browsers.append( |
| + PossibleIEDesktopBrowser('webdriver.ie%s' % bit, options, bit)) |
| + |
| + return browsers |