Skip to content

Commit

Permalink
python - set is_remote flag to determine if class is remote
Browse files Browse the repository at this point in the history
This is used by webelement when sending keys, to determine if the keys being sent is a real file that it should upload to the standalone server.
Also fixed a minor test issue.
Updated copyright headers of files affected.
Fixes Issue 4877.
Fixes Issue 5017.
  • Loading branch information
lukeis committed Jan 17, 2013
1 parent ff2de50 commit 87a9f03
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions py/selenium/webdriver/chrome/webdriver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/python
#
# Copyright 2011 Webdriver_name committers
# Copyright 2011 Google Inc.
# Copyright 2011-2013 Software freedom conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -67,6 +66,7 @@ def __init__(self, executable_path="chromedriver", port=0,
except:
self.quit()
raise
self._is_remote = False

def quit(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/firefox/webdriver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright 2008-2011 WebDriver committers
# Copyright 2008-2011 Google Inc.
# Copyright 2008-2013 Software freedom conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,6 +57,7 @@ def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30,
command_executor=ExtensionConnection("127.0.0.1", self.profile,
self.binary, timeout),
desired_capabilities=capabilities)
self._is_remote = False

def create_web_element(self, element_id):
"""Override from RemoteWebDriver to use firefox.WebElement."""
Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/ie/webdriver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/python
#
# Copyright 2008-2010 WebDriver committers
# Copyright 2008-2010 Google Inc.
# Copyright 2008-2013 Software freedom conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -50,6 +49,7 @@ def __init__(self, executable_path='IEDriverServer.exe',
self,
command_executor='http://localhost:%d' % self.port,
desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
self._is_remote = False

def quit(self):
RemoteWebDriver.quit(self)
Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/opera/webdriver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/python
#
# Copyright 2011 Webdriver_name committers
# Copyright 2011 Google Inc.
# Copyright 2011-2013 Sofware freedom conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,6 +53,7 @@ def __init__(self, executable_path=None, port=0,
RemoteWebDriver.__init__(self,
command_executor=self.service.service_url,
desired_capabilities=desired_capabilities)
self._is_remote = False

def quit(self):
"""
Expand Down
4 changes: 3 additions & 1 deletion py/selenium/webdriver/phantomjs/webdriver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python
#
# Copyright 2012 Software freedom conservancy
# Copyright 2012-2013 Software freedom conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,6 +54,8 @@ def __init__(self, executable_path="phantomjs",
self.quit()
raise

self._is_remote = False

def quit(self):
"""
Closes the browser and shuts down the PhantomJS executable
Expand Down
4 changes: 2 additions & 2 deletions py/selenium/webdriver/remote/webdriver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright 2008-2011 WebDriver committers
# Copyright 2008-2011 Google Inc.
# Copyright 2008-2013 Software freedom conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,6 +59,7 @@ def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',
self.command_executor = command_executor
if type(self.command_executor) is str or type(self.command_executor) is unicode:
self.command_executor = RemoteConnection(command_executor)
self._is_remote = True
self.session_id = None
self.capabilities = {}
self.error_handler = ErrorHandler()
Expand Down
12 changes: 4 additions & 8 deletions py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Copyright 2008-2009 WebDriver committers
# Copyright 2008-2009 Google Inc.
# Copyright 2008-2013 Software freedom conservancy
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -139,12 +138,9 @@ def find_elements_by_css_selector(self, css_selector):

def send_keys(self, *value):
"""Simulates typing into the element."""
# transfer file to another machine only if remote driver is used
# the same behaviour as for java binding
parent_class = self.parent.__class__
fqcn = parent_class.__module__ + "." + parent_class.__name__
is_remote = fqcn == "selenium.webdriver.remote.webdriver.WebDriver"
if is_remote:
# transfer file to another machine only if remote driver is used
# the same behaviour as for java binding
if self.parent._is_remote:
local_file = LocalFileDetector.is_local_file(*value)
if local_file is not None:
value = self._upload(local_file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


from selenium import webdriver
from selenium.test.selenium.webdriver.support import select_class_tests
from selenium.test.selenium.webdriver.common import select_class_tests
from selenium.test.selenium.webdriver.common.webserver import SimpleWebServer

def setup_module(module):
Expand Down

0 comments on commit 87a9f03

Please sign in to comment.