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

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

Issue 7629019: Revert 96556 - Let pyauto create an attached webdriver instance to manipulate web pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
« no previous file with comments | « chrome/test/functional/pyauto_webdriver.py ('k') | chrome/test/pyautolib/pyauto.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 96579)
+++ chrome/test/pyautolib/chrome_driver_factory.py (working copy)
@@ -1,62 +0,0 @@
-#!/usr/bin/python
-# Copyright (c) 2011 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):
- 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
- """
- 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})
-
- 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_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 __del__(self):
- self.Stop()
-
« no previous file with comments | « chrome/test/functional/pyauto_webdriver.py ('k') | chrome/test/pyautolib/pyauto.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698