Created
January 2, 2014 19:24
-
-
Save weissjeffm/8224962 to your computer and use it in GitHub Desktop.
legacy sel fail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================= test session starts ============================== | |
platform linux2 -- Python 2.7.5 -- pytest-2.5.1 | |
collected 243 items | |
cfme/tests/test_login.py .. | |
tests/test_phantom_login.py E | |
tests/ui/test_login.py E | |
==================================== ERRORS ==================================== | |
_____________________ ERROR at setup of test_phantom_login _____________________ | |
@pytest.yield_fixture(scope='module') | |
def browser(): | |
> with utils.browser.browser_session() as session: | |
yield session | |
fixtures/browser.py:10: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <contextlib.GeneratorContextManager object at 0x6d98450> | |
def __enter__(self): | |
try: | |
> return self.gen.next() | |
/usr/lib64/python2.7/contextlib.py:17: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = (), kwargs = {} | |
@contextmanager | |
def browser_session(*args, **kwargs): | |
> browser = start(*args, **kwargs) | |
utils/browser.py:52: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_webdriver = <class 'selenium.webdriver.remote.webdriver.WebDriver'> | |
base_url = 'https://http://10.8.59.174', kwargs = {} | |
browser_kwargs = {'desired_capabilities': {'browserName': 'chrome', 'platform': 'LINUX'}} | |
def start(_webdriver=None, base_url=None, **kwargs): | |
# Sanity check in the unlikely event of a nested session | |
if thread_locals.browser is None: | |
if _webdriver is None: | |
# If unset, look to the config for the webdriver type | |
# defaults to Firefox | |
_webdriver = conf.env['browser'].get('webdriver', 'Firefox') | |
if isinstance(_webdriver, basestring): | |
# Try to convert _webdriver str into a webdriver by name | |
# e.g. 'Firefox', 'Chrome', RemoteJS', useful for interactive development | |
_webdriver = getattr(webdriver, _webdriver) | |
# else: assume _webdriver is a WebDriver class already | |
if base_url is None: | |
base_url = conf.env['base_url'] | |
# Pull in browser kwargs from browser yaml | |
browser_kwargs = conf.env['browser'].get('webdriver_options', {}) | |
# Update it with passed-in options/overrides | |
browser_kwargs.update(kwargs) | |
> browser = WebDriverWrapper(_webdriver(**browser_kwargs), base_url) | |
utils/browser.py:42: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.webdriver.WebDriver object at 0x6d984d0> | |
command_executor = 'http://127.0.0.1:4444/wd/hub' | |
desired_capabilities = {'browserName': 'chrome', 'platform': 'LINUX'} | |
browser_profile = None, proxy = None, keep_alive = False | |
def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub', | |
desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=False): | |
""" | |
Create a new driver that will issue commands using the wire protocol. | |
:Args: | |
- command_executor - Either a command.CommandExecutor object or a string that specifies the URL of a remote server to send commands to. | |
- desired_capabilities - Dictionary holding predefined values for starting a browser | |
- browser_profile - A selenium.webdriver.firefox.firefox_profile.FirefoxProfile object. Only used if Firefox is requested. | |
""" | |
if desired_capabilities is None: | |
raise WebDriverException("Desired Capabilities can't be None") | |
if not isinstance(desired_capabilities, dict): | |
raise WebDriverException("Desired Capabilities must be a dictionary") | |
if proxy is not None: | |
proxy.add_to_capabilities(desired_capabilities) | |
self.command_executor = command_executor | |
if type(self.command_executor) is bytes or type(self.command_executor) is str: | |
self.command_executor = RemoteConnection(command_executor, keep_alive=keep_alive) | |
self._is_remote = True | |
self.session_id = None | |
self.capabilities = {} | |
self.error_handler = ErrorHandler() | |
self.start_client() | |
> self.start_session(desired_capabilities, browser_profile) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:71: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.webdriver.WebDriver object at 0x6d984d0> | |
desired_capabilities = {'browserName': 'chrome', 'platform': 'LINUX'} | |
browser_profile = None | |
def start_session(self, desired_capabilities, browser_profile=None): | |
""" | |
Creates a new session with the desired capabilities. | |
:Args: | |
- browser_name - The name of the browser to request. | |
- version - Which browser version to request. | |
- platform - Which platform to request the browser on. | |
- javascript_enabled - Whether the new session should support JavaScript. | |
- browser_profile - A selenium.webdriver.firefox.firefox_profile.FirefoxProfile object. Only used if Firefox is requested. | |
""" | |
if browser_profile: | |
desired_capabilities['firefox_profile'] = browser_profile.encoded | |
response = self.execute(Command.NEW_SESSION, { | |
> 'desiredCapabilities': desired_capabilities, | |
}) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:113: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.webdriver.WebDriver object at 0x6d984d0> | |
driver_command = 'newSession' | |
params = {'desiredCapabilities': {'browserName': 'chrome', 'platform': 'LINUX'}, 'sessionId': None} | |
def execute(self, driver_command, params=None): | |
""" | |
Sends a command to be executed by a command.CommandExecutor. | |
:Args: | |
- driver_command: The name of the command to execute as a string. | |
- params: A dictionary of named parameters to send with the command. | |
:Returns: | |
The command's JSON response loaded into a dictionary object. | |
""" | |
if not params: | |
params = {'sessionId': self.session_id} | |
elif 'sessionId' not in params: | |
params['sessionId'] = self.session_id | |
params = self._wrap_value(params) | |
> response = self.command_executor.execute(driver_command, params) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:162: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.remote_connection.RemoteConnection object at 0x6d981d0> | |
command = 'newSession' | |
params = {'desiredCapabilities': {'browserName': 'chrome', 'platform': 'LINUX'}, 'sessionId': None} | |
def execute(self, command, params): | |
""" | |
Send a command to the remote server. | |
Any path subtitutions required for the URL mapped to the command should be | |
included in the command parameters. | |
:Args: | |
- command - A string specifying the command to execute. | |
- params - A dictionary of named parameters to send with the command as | |
its JSON payload. | |
""" | |
command_info = self._commands[command] | |
assert command_info is not None, 'Unrecognised command %s' % command | |
data = utils.dump_json(params) | |
path = string.Template(command_info[1]).substitute(params) | |
url = '%s%s' % (self._url, path) | |
> return self._request(url, method=command_info[0], data=data) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:349: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.remote_connection.RemoteConnection object at 0x6d981d0> | |
url = 'http://127.0.0.1:4444/wd/hub/session' | |
data = '{"sessionId": null, "desiredCapabilities": {"platform": "LINUX", "browserName": "chrome"}}' | |
method = 'POST' | |
def _request(self, url, data=None, method=None): | |
""" | |
Send an HTTP request to the remote server. | |
:Args: | |
- method - A string for the HTTP method to send the request with. | |
- url - The URL to send the request to. | |
- body - The message body to send. | |
:Returns: | |
A dictionary with the server's parsed JSON response. | |
""" | |
LOGGER.debug('%s %s %s' % (method, url, data)) | |
parsed_url = parse.urlparse(url) | |
if self.keep_alive: | |
headers = {"Connection": 'keep-alive', method: parsed_url.path, | |
"User-Agent": "Python http auth", | |
"Content-type": "application/json;charset=\"UTF-8\"", | |
"Accept": "application/json"} | |
if parsed_url.username: | |
auth = base64.standard_b64encode('%s:%s' % | |
(parsed_url.username, parsed_url.password)).replace('\n', '') | |
headers["Authorization"] = "Basic %s" % auth | |
self._conn.request(method, parsed_url.path, data, headers) | |
resp = self._conn.getresponse() | |
statuscode = resp.status | |
else: | |
password_manager = None | |
if parsed_url.username: | |
netloc = parsed_url.hostname | |
if parsed_url.port: | |
netloc += ":%s" % parsed_url.port | |
cleaned_url = parse.urlunparse((parsed_url.scheme, | |
netloc, | |
parsed_url.path, | |
parsed_url.params, | |
parsed_url.query, | |
parsed_url.fragment)) | |
password_manager = url_request.HTTPPasswordMgrWithDefaultRealm() | |
password_manager.add_password(None, | |
"%s://%s" % (parsed_url.scheme, netloc), | |
parsed_url.username, | |
parsed_url.password) | |
request = Request(cleaned_url, data=data.encode('utf-8'), method=method) | |
else: | |
request = Request(url, data=data.encode('utf-8'), method=method) | |
request.add_header('Accept', 'application/json') | |
request.add_header('Content-Type', 'application/json;charset=UTF-8') | |
if password_manager: | |
opener = url_request.build_opener(url_request.HTTPRedirectHandler(), | |
HttpErrorHandler(), | |
url_request.HTTPBasicAuthHandler(password_manager)) | |
else: | |
opener = url_request.build_opener(url_request.HTTPRedirectHandler(), | |
HttpErrorHandler()) | |
> resp = opener.open(request) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:410: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.OpenerDirector instance at 0x6d96908> | |
fullurl = <selenium.webdriver.remote.remote_connection.Request instance at 0x6d96b48> | |
data = None, timeout = <object object at 0x7f0fce677110> | |
def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
# accept a URL or a Request object | |
if isinstance(fullurl, basestring): | |
req = Request(fullurl, data) | |
else: | |
req = fullurl | |
if data is not None: | |
req.add_data(data) | |
req.timeout = timeout | |
protocol = req.get_type() | |
# pre-process request | |
meth_name = protocol+"_request" | |
for processor in self.process_request.get(protocol, []): | |
meth = getattr(processor, meth_name) | |
req = meth(req) | |
> response = self._open(req, data) | |
/usr/lib64/python2.7/urllib2.py:404: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.OpenerDirector instance at 0x6d96908> | |
req = <selenium.webdriver.remote.remote_connection.Request instance at 0x6d96b48> | |
data = None | |
def _open(self, req, data=None): | |
result = self._call_chain(self.handle_open, 'default', | |
'default_open', req) | |
if result: | |
return result | |
protocol = req.get_type() | |
result = self._call_chain(self.handle_open, protocol, protocol + | |
> '_open', req) | |
/usr/lib64/python2.7/urllib2.py:422: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.OpenerDirector instance at 0x6d96908> | |
chain = {'file': [<urllib2.FileHandler instance at 0x6d96ab8>], 'ftp': [<urllib2.FTPHandler instance at 0x6d969e0>], 'http': [<urllib2.HTTPHandler instance at 0x6d96998>], 'https': [<urllib2.HTTPSHandler instance at 0x6d96878>], ...} | |
kind = 'http', meth_name = 'http_open' | |
args = (<selenium.webdriver.remote.remote_connection.Request instance at 0x6d96b48>,) | |
handlers = [<urllib2.HTTPHandler instance at 0x6d96998>] | |
handler = <urllib2.HTTPHandler instance at 0x6d96998> | |
func = <bound method HTTPHandler.http_open of <urllib2.HTTPHandler instance at 0x6d96998>> | |
def _call_chain(self, chain, kind, meth_name, *args): | |
# Handlers raise an exception if no one else should try to handle | |
# the request, or return None if they can't but another handler | |
# could. Otherwise, they return the response. | |
handlers = chain.get(kind, ()) | |
for handler in handlers: | |
func = getattr(handler, meth_name) | |
> result = func(*args) | |
/usr/lib64/python2.7/urllib2.py:382: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.HTTPHandler instance at 0x6d96998> | |
req = <selenium.webdriver.remote.remote_connection.Request instance at 0x6d96b48> | |
def http_open(self, req): | |
> return self.do_open(httplib.HTTPConnection, req) | |
/usr/lib64/python2.7/urllib2.py:1216: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.HTTPHandler instance at 0x6d96998> | |
http_class = <class httplib.HTTPConnection at 0x25260b8> | |
req = <selenium.webdriver.remote.remote_connection.Request instance at 0x6d96b48> | |
def do_open(self, http_class, req): | |
"""Return an addinfourl object for the request, using http_class. | |
http_class must implement the HTTPConnection API from httplib. | |
The addinfourl return value is a file-like object. It also | |
has methods and attributes including: | |
- info(): return a mimetools.Message object for the headers | |
- geturl(): return the original request URL | |
- code: HTTP status code | |
""" | |
host = req.get_host() | |
if not host: | |
raise URLError('no host given') | |
h = http_class(host, timeout=req.timeout) # will parse host:port | |
h.set_debuglevel(self._debuglevel) | |
headers = dict(req.unredirected_hdrs) | |
headers.update(dict((k, v) for k, v in req.headers.items() | |
if k not in headers)) | |
# We want to make an HTTP/1.1 request, but the addinfourl | |
# class isn't prepared to deal with a persistent connection. | |
# It will try to read all remaining data from the socket, | |
# which will block while the server waits for the next request. | |
# So make sure the connection gets closed after the (only) | |
# request. | |
headers["Connection"] = "close" | |
headers = dict( | |
(name.title(), val) for name, val in headers.items()) | |
if req._tunnel_host: | |
tunnel_headers = {} | |
proxy_auth_hdr = "Proxy-Authorization" | |
if proxy_auth_hdr in headers: | |
tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr] | |
# Proxy-Authorization should not be sent to origin | |
# server. | |
del headers[proxy_auth_hdr] | |
h.set_tunnel(req._tunnel_host, headers=tunnel_headers) | |
try: | |
h.request(req.get_method(), req.get_selector(), req.data, headers) | |
except socket.error, err: # XXX what error? | |
h.close() | |
> raise URLError(err) | |
E URLError: <urlopen error [Errno 111] Connection refused> | |
/usr/lib64/python2.7/urllib2.py:1186: URLError | |
____________________ ERROR at setup of TestLogin.test_login ____________________ | |
@pytest.yield_fixture(scope='module') | |
def browser(): | |
> with utils.browser.browser_session() as session: | |
yield session | |
fixtures/browser.py:10: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <contextlib.GeneratorContextManager object at 0x6dbd210> | |
def __enter__(self): | |
try: | |
> return self.gen.next() | |
/usr/lib64/python2.7/contextlib.py:17: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = (), kwargs = {} | |
@contextmanager | |
def browser_session(*args, **kwargs): | |
> browser = start(*args, **kwargs) | |
utils/browser.py:52: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_webdriver = <class 'selenium.webdriver.remote.webdriver.WebDriver'> | |
base_url = 'https://http://10.8.59.174', kwargs = {} | |
browser_kwargs = {'desired_capabilities': {'browserName': 'chrome', 'platform': 'LINUX'}} | |
def start(_webdriver=None, base_url=None, **kwargs): | |
# Sanity check in the unlikely event of a nested session | |
if thread_locals.browser is None: | |
if _webdriver is None: | |
# If unset, look to the config for the webdriver type | |
# defaults to Firefox | |
_webdriver = conf.env['browser'].get('webdriver', 'Firefox') | |
if isinstance(_webdriver, basestring): | |
# Try to convert _webdriver str into a webdriver by name | |
# e.g. 'Firefox', 'Chrome', RemoteJS', useful for interactive development | |
_webdriver = getattr(webdriver, _webdriver) | |
# else: assume _webdriver is a WebDriver class already | |
if base_url is None: | |
base_url = conf.env['base_url'] | |
# Pull in browser kwargs from browser yaml | |
browser_kwargs = conf.env['browser'].get('webdriver_options', {}) | |
# Update it with passed-in options/overrides | |
browser_kwargs.update(kwargs) | |
> browser = WebDriverWrapper(_webdriver(**browser_kwargs), base_url) | |
utils/browser.py:42: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.webdriver.WebDriver object at 0x6dbd410> | |
command_executor = 'http://127.0.0.1:4444/wd/hub' | |
desired_capabilities = {'browserName': 'chrome', 'platform': 'LINUX'} | |
browser_profile = None, proxy = None, keep_alive = False | |
def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub', | |
desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=False): | |
""" | |
Create a new driver that will issue commands using the wire protocol. | |
:Args: | |
- command_executor - Either a command.CommandExecutor object or a string that specifies the URL of a remote server to send commands to. | |
- desired_capabilities - Dictionary holding predefined values for starting a browser | |
- browser_profile - A selenium.webdriver.firefox.firefox_profile.FirefoxProfile object. Only used if Firefox is requested. | |
""" | |
if desired_capabilities is None: | |
raise WebDriverException("Desired Capabilities can't be None") | |
if not isinstance(desired_capabilities, dict): | |
raise WebDriverException("Desired Capabilities must be a dictionary") | |
if proxy is not None: | |
proxy.add_to_capabilities(desired_capabilities) | |
self.command_executor = command_executor | |
if type(self.command_executor) is bytes or type(self.command_executor) is str: | |
self.command_executor = RemoteConnection(command_executor, keep_alive=keep_alive) | |
self._is_remote = True | |
self.session_id = None | |
self.capabilities = {} | |
self.error_handler = ErrorHandler() | |
self.start_client() | |
> self.start_session(desired_capabilities, browser_profile) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:71: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.webdriver.WebDriver object at 0x6dbd410> | |
desired_capabilities = {'browserName': 'chrome', 'platform': 'LINUX'} | |
browser_profile = None | |
def start_session(self, desired_capabilities, browser_profile=None): | |
""" | |
Creates a new session with the desired capabilities. | |
:Args: | |
- browser_name - The name of the browser to request. | |
- version - Which browser version to request. | |
- platform - Which platform to request the browser on. | |
- javascript_enabled - Whether the new session should support JavaScript. | |
- browser_profile - A selenium.webdriver.firefox.firefox_profile.FirefoxProfile object. Only used if Firefox is requested. | |
""" | |
if browser_profile: | |
desired_capabilities['firefox_profile'] = browser_profile.encoded | |
response = self.execute(Command.NEW_SESSION, { | |
> 'desiredCapabilities': desired_capabilities, | |
}) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:113: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.webdriver.WebDriver object at 0x6dbd410> | |
driver_command = 'newSession' | |
params = {'desiredCapabilities': {'browserName': 'chrome', 'platform': 'LINUX'}, 'sessionId': None} | |
def execute(self, driver_command, params=None): | |
""" | |
Sends a command to be executed by a command.CommandExecutor. | |
:Args: | |
- driver_command: The name of the command to execute as a string. | |
- params: A dictionary of named parameters to send with the command. | |
:Returns: | |
The command's JSON response loaded into a dictionary object. | |
""" | |
if not params: | |
params = {'sessionId': self.session_id} | |
elif 'sessionId' not in params: | |
params['sessionId'] = self.session_id | |
params = self._wrap_value(params) | |
> response = self.command_executor.execute(driver_command, params) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:162: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.remote_connection.RemoteConnection object at 0x6dbd450> | |
command = 'newSession' | |
params = {'desiredCapabilities': {'browserName': 'chrome', 'platform': 'LINUX'}, 'sessionId': None} | |
def execute(self, command, params): | |
""" | |
Send a command to the remote server. | |
Any path subtitutions required for the URL mapped to the command should be | |
included in the command parameters. | |
:Args: | |
- command - A string specifying the command to execute. | |
- params - A dictionary of named parameters to send with the command as | |
its JSON payload. | |
""" | |
command_info = self._commands[command] | |
assert command_info is not None, 'Unrecognised command %s' % command | |
data = utils.dump_json(params) | |
path = string.Template(command_info[1]).substitute(params) | |
url = '%s%s' % (self._url, path) | |
> return self._request(url, method=command_info[0], data=data) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:349: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <selenium.webdriver.remote.remote_connection.RemoteConnection object at 0x6dbd450> | |
url = 'http://127.0.0.1:4444/wd/hub/session' | |
data = '{"sessionId": null, "desiredCapabilities": {"platform": "LINUX", "browserName": "chrome"}}' | |
method = 'POST' | |
def _request(self, url, data=None, method=None): | |
""" | |
Send an HTTP request to the remote server. | |
:Args: | |
- method - A string for the HTTP method to send the request with. | |
- url - The URL to send the request to. | |
- body - The message body to send. | |
:Returns: | |
A dictionary with the server's parsed JSON response. | |
""" | |
LOGGER.debug('%s %s %s' % (method, url, data)) | |
parsed_url = parse.urlparse(url) | |
if self.keep_alive: | |
headers = {"Connection": 'keep-alive', method: parsed_url.path, | |
"User-Agent": "Python http auth", | |
"Content-type": "application/json;charset=\"UTF-8\"", | |
"Accept": "application/json"} | |
if parsed_url.username: | |
auth = base64.standard_b64encode('%s:%s' % | |
(parsed_url.username, parsed_url.password)).replace('\n', '') | |
headers["Authorization"] = "Basic %s" % auth | |
self._conn.request(method, parsed_url.path, data, headers) | |
resp = self._conn.getresponse() | |
statuscode = resp.status | |
else: | |
password_manager = None | |
if parsed_url.username: | |
netloc = parsed_url.hostname | |
if parsed_url.port: | |
netloc += ":%s" % parsed_url.port | |
cleaned_url = parse.urlunparse((parsed_url.scheme, | |
netloc, | |
parsed_url.path, | |
parsed_url.params, | |
parsed_url.query, | |
parsed_url.fragment)) | |
password_manager = url_request.HTTPPasswordMgrWithDefaultRealm() | |
password_manager.add_password(None, | |
"%s://%s" % (parsed_url.scheme, netloc), | |
parsed_url.username, | |
parsed_url.password) | |
request = Request(cleaned_url, data=data.encode('utf-8'), method=method) | |
else: | |
request = Request(url, data=data.encode('utf-8'), method=method) | |
request.add_header('Accept', 'application/json') | |
request.add_header('Content-Type', 'application/json;charset=UTF-8') | |
if password_manager: | |
opener = url_request.build_opener(url_request.HTTPRedirectHandler(), | |
HttpErrorHandler(), | |
url_request.HTTPBasicAuthHandler(password_manager)) | |
else: | |
opener = url_request.build_opener(url_request.HTTPRedirectHandler(), | |
HttpErrorHandler()) | |
> resp = opener.open(request) | |
../../.virtualenvs/cfme/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py:410: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.OpenerDirector instance at 0x6db7cb0> | |
fullurl = <selenium.webdriver.remote.remote_connection.Request instance at 0x6db75f0> | |
data = None, timeout = <object object at 0x7f0fce677110> | |
def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): | |
# accept a URL or a Request object | |
if isinstance(fullurl, basestring): | |
req = Request(fullurl, data) | |
else: | |
req = fullurl | |
if data is not None: | |
req.add_data(data) | |
req.timeout = timeout | |
protocol = req.get_type() | |
# pre-process request | |
meth_name = protocol+"_request" | |
for processor in self.process_request.get(protocol, []): | |
meth = getattr(processor, meth_name) | |
req = meth(req) | |
> response = self._open(req, data) | |
/usr/lib64/python2.7/urllib2.py:404: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.OpenerDirector instance at 0x6db7cb0> | |
req = <selenium.webdriver.remote.remote_connection.Request instance at 0x6db75f0> | |
data = None | |
def _open(self, req, data=None): | |
result = self._call_chain(self.handle_open, 'default', | |
'default_open', req) | |
if result: | |
return result | |
protocol = req.get_type() | |
result = self._call_chain(self.handle_open, protocol, protocol + | |
> '_open', req) | |
/usr/lib64/python2.7/urllib2.py:422: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.OpenerDirector instance at 0x6db7cb0> | |
chain = {'file': [<urllib2.FileHandler instance at 0x6cd6320>], 'ftp': [<urllib2.FTPHandler instance at 0x6810050>], 'http': [<urllib2.HTTPHandler instance at 0x6810098>], 'https': [<urllib2.HTTPSHandler instance at 0x6cd6200>], ...} | |
kind = 'http', meth_name = 'http_open' | |
args = (<selenium.webdriver.remote.remote_connection.Request instance at 0x6db75f0>,) | |
handlers = [<urllib2.HTTPHandler instance at 0x6810098>] | |
handler = <urllib2.HTTPHandler instance at 0x6810098> | |
func = <bound method HTTPHandler.http_open of <urllib2.HTTPHandler instance at 0x6810098>> | |
def _call_chain(self, chain, kind, meth_name, *args): | |
# Handlers raise an exception if no one else should try to handle | |
# the request, or return None if they can't but another handler | |
# could. Otherwise, they return the response. | |
handlers = chain.get(kind, ()) | |
for handler in handlers: | |
func = getattr(handler, meth_name) | |
> result = func(*args) | |
/usr/lib64/python2.7/urllib2.py:382: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.HTTPHandler instance at 0x6810098> | |
req = <selenium.webdriver.remote.remote_connection.Request instance at 0x6db75f0> | |
def http_open(self, req): | |
> return self.do_open(httplib.HTTPConnection, req) | |
/usr/lib64/python2.7/urllib2.py:1216: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <urllib2.HTTPHandler instance at 0x6810098> | |
http_class = <class httplib.HTTPConnection at 0x25260b8> | |
req = <selenium.webdriver.remote.remote_connection.Request instance at 0x6db75f0> | |
def do_open(self, http_class, req): | |
"""Return an addinfourl object for the request, using http_class. | |
http_class must implement the HTTPConnection API from httplib. | |
The addinfourl return value is a file-like object. It also | |
has methods and attributes including: | |
- info(): return a mimetools.Message object for the headers | |
- geturl(): return the original request URL | |
- code: HTTP status code | |
""" | |
host = req.get_host() | |
if not host: | |
raise URLError('no host given') | |
h = http_class(host, timeout=req.timeout) # will parse host:port | |
h.set_debuglevel(self._debuglevel) | |
headers = dict(req.unredirected_hdrs) | |
headers.update(dict((k, v) for k, v in req.headers.items() | |
if k not in headers)) | |
# We want to make an HTTP/1.1 request, but the addinfourl | |
# class isn't prepared to deal with a persistent connection. | |
# It will try to read all remaining data from the socket, | |
# which will block while the server waits for the next request. | |
# So make sure the connection gets closed after the (only) | |
# request. | |
headers["Connection"] = "close" | |
headers = dict( | |
(name.title(), val) for name, val in headers.items()) | |
if req._tunnel_host: | |
tunnel_headers = {} | |
proxy_auth_hdr = "Proxy-Authorization" | |
if proxy_auth_hdr in headers: | |
tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr] | |
# Proxy-Authorization should not be sent to origin | |
# server. | |
del headers[proxy_auth_hdr] | |
h.set_tunnel(req._tunnel_host, headers=tunnel_headers) | |
try: | |
h.request(req.get_method(), req.get_selector(), req.data, headers) | |
except socket.error, err: # XXX what error? | |
h.close() | |
> raise URLError(err) | |
E URLError: <urlopen error [Errno 111] Connection refused> | |
/usr/lib64/python2.7/urllib2.py:1186: URLError | |
====================== 239 tests deselected by '-klogin' ======================= | |
============== 2 passed, 239 deselected, 2 error in 10.29 seconds ============== | |
Event testing disabled, no collecting, no reports |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment