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

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

Issue 222873002: Remove pyauto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 9 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
« no previous file with comments | « chrome/test/pyautolib/bookmark_model.py ('k') | chrome/test/pyautolib/chromeos/chromeos_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/chrome_driver_factory.py
===================================================================
--- chrome/test/pyautolib/chrome_driver_factory.py (revision 261231)
+++ chrome/test/pyautolib/chrome_driver_factory.py (working copy)
@@ -1,82 +0,0 @@
-# Copyright (c) 2012 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.
-
-"""Factory that creates ChromeDriver instances for pyauto."""
-
-import os
-import random
-import tempfile
-
-import pyauto_paths
-from selenium import webdriver
-from selenium.webdriver.chrome import service
-
-
-class ChromeDriverFactory(object):
- """"Factory that creates ChromeDriver instances for pyauto.
-
- Starts a single ChromeDriver server when necessary. Users should call 'Stop'
- when no longer using the factory.
- """
-
- def __init__(self, port=0):
- """Initialize ChromeDriverFactory.
-
- Args:
- port: The port for WebDriver to use; by default the service will select a
- free port.
- """
- self._chromedriver_port = port
- self._chromedriver_server = None
-
- def NewChromeDriver(self, pyauto):
- """Creates a new remote WebDriver instance.
-
- This instance will connect to a new automation provider of an already
- running Chrome.
-
- Args:
- pyauto: pyauto.PyUITest instance
-
- Returns:
- selenium.webdriver.remote.webdriver.WebDriver instance.
- """
- if pyauto.IsChromeOS():
- os.putenv('DISPLAY', ':0.0')
- os.putenv('XAUTHORITY', '/home/chronos/.Xauthority')
- self._StartServerIfNecessary()
- channel_id = 'testing' + hex(random.getrandbits(20 * 4))[2:-1]
- if not pyauto.IsWin():
- channel_id = os.path.join(tempfile.gettempdir(), channel_id)
- pyauto.CreateNewAutomationProvider(channel_id)
- return webdriver.Remote(self._chromedriver_server.service_url,
- {'chrome.channel': channel_id,
- 'chrome.noWebsiteTestingDefaults': True})
-
- def _StartServerIfNecessary(self):
- """Starts the ChromeDriver server, if not already started."""
- if self._chromedriver_server is None:
- exe = pyauto_paths.GetChromeDriverExe()
- assert exe, 'Cannot find chromedriver exe. Did you build it?'
- self._chromedriver_server = service.Service(exe, self._chromedriver_port)
- self._chromedriver_server.start()
-
- def Stop(self):
- """Stops the ChromeDriver server, if running."""
- if self._chromedriver_server is not None:
- self._chromedriver_server.stop()
- self._chromedriver_server = None
-
- def GetPort(self):
- """Gets the port ChromeDriver is set to use.
-
- Returns:
- The port all ChromeDriver instances returned from NewChromeDriver() will
- be listening on. A return value of 0 indicates the ChromeDriver service
- will select a free port.
- """
- return self._chromedriver_port
-
- def __del__(self):
- self.Stop()
« no previous file with comments | « chrome/test/pyautolib/bookmark_model.py ('k') | chrome/test/pyautolib/chromeos/chromeos_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698