Skip to content

Commit 9bec103

Browse files
David Lailukeis
authored andcommitted
Update DesiredCapabilities doc comments to use .copy() in the examples.
clean up mix if tab and space characters. Issue 6486 Signed-off-by: Luke Inman-Semerau <luke.semerau@gmail.com>
1 parent 01c0c09 commit 9bec103

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

py/selenium/webdriver/common/desired_capabilities.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
class DesiredCapabilities(object):
2121
"""
22-
Set of supported desired capabilities.
23-
22+
Set of default supported desired capabilities.
23+
2424
Use this as a starting point for creating a desired capabilities object for
25-
requesting remote webdrivers from selenium server or selenium grid.
25+
requesting remote webdrivers for connecting to selenium server or selenium grid.
2626
2727
2828
Usage Example:
@@ -32,14 +32,16 @@ class DesiredCapabilities(object):
3232
selenium_grid_url = "http://198.0.0.1:4444/wd/hub"
3333
3434
# Create a desired capabilities object as a starting point.
35-
capabilities = DesiredCapabilities.FIREFOX
35+
capabilities = DesiredCapabilities.FIREFOX.copy()
3636
capabilities['platform'] = "WINDOWS"
3737
capabilities['version'] = "10"
3838
3939
# Instantiate an instance of Remote WebDriver with the desired capabilities.
4040
driver = webdriver.Remote(desired_capabilities=capabilities,
41-
command_executor=selenium_grid_url)
41+
command_executor=selenium_grid_url)
4242
43+
Note: Always use '.copy()' on the DesiredCapabilities object to avoid the side
44+
effects of altering the Global class instance.
4345
4446
"""
4547

@@ -111,7 +113,7 @@ class DesiredCapabilities(object):
111113
"platform": "ANDROID",
112114
"javascriptEnabled": True,
113115
}
114-
116+
115117
PHANTOMJS = {
116118
"browserName":"phantomjs",
117119
"version": "",

py/selenium/webdriver/firefox/extension_connection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def quit(self, sessionId=None):
5757

5858
def connect(self):
5959
"""Connects to the extension and retrieves the session id."""
60-
return self.execute(Command.NEW_SESSION, {'desiredCapabilities': DesiredCapabilities.FIREFOX})
60+
return self.execute(Command.NEW_SESSION,
61+
{'desiredCapabilities': DesiredCapabilities.FIREFOX})
6162

6263
@classmethod
6364
def connect_and_quit(self):

py/selenium/webdriver/support/wait.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
from selenium.common.exceptions import TimeoutException
2020

2121
POLL_FREQUENCY = 0.5 # How long to sleep inbetween calls to the method
22-
IGNORED_EXCEPTIONS = [NoSuchElementException] # list of exceptions ignored during calls to the method
22+
IGNORED_EXCEPTIONS = [NoSuchElementException] # list of exceptions ignored during calls to the method
2323

2424
class WebDriverWait(object):
2525

2626
def __init__(self, driver, timeout, poll_frequency=POLL_FREQUENCY, ignored_exceptions=None):
2727
"""Constructor, takes a WebDriver instance and timeout in seconds.
28-
28+
2929
:Args:
3030
- driver - Instance of WebDriver (Ie, Firefox, Chrome or Remote)
3131
- timeout - Number of seconds before timing out
@@ -50,7 +50,7 @@ def __init__(self, driver, timeout, poll_frequency=POLL_FREQUENCY, ignored_excep
5050
if ignored_exceptions is not None:
5151
try:
5252
exceptions.extend(iter(ignored_exceptions))
53-
except TypeError: # ignored_exceptions is not iterable
53+
except TypeError: # ignored_exceptions is not iterable
5454
exceptions.append(ignored_exceptions)
5555
self._ignored_exceptions = tuple(exceptions)
5656

@@ -71,17 +71,17 @@ def until(self, method, message=''):
7171
raise TimeoutException(message)
7272

7373
def until_not(self, method, message=''):
74-
"""Calls the method provided with the driver as an argument until the \
75-
return value is False."""
76-
end_time = time.time() + self._timeout
77-
while(True):
78-
try:
79-
value = method(self._driver)
80-
if not value:
81-
return value
82-
except self._ignored_exceptions:
83-
return True
84-
time.sleep(self._poll)
85-
if(time.time() > end_time):
86-
break
87-
raise TimeoutException(message)
74+
"""Calls the method provided with the driver as an argument until the \
75+
return value is False."""
76+
end_time = time.time() + self._timeout
77+
while(True):
78+
try:
79+
value = method(self._driver)
80+
if not value:
81+
return value
82+
except self._ignored_exceptions:
83+
return True
84+
time.sleep(self._poll)
85+
if(time.time() > end_time):
86+
break
87+
raise TimeoutException(message)

0 commit comments

Comments
 (0)