Skip to content

Commit 59ba9ff

Browse files
committed
Merge pull request #15 from bayandin/fixes
Numerous fixes
2 parents ee0dafc + 78983a1 commit 59ba9ff

23 files changed

+158
-160
lines changed

appium/common/exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414

1515
from selenium.common.exceptions import InvalidSwitchToTargetException
1616

17+
1718
class NoSuchContextException(InvalidSwitchToTargetException):
1819
"""
1920
Thrown when context target to be switched doesn't exist.
2021
2122
To find the current set of active contexts, you can get a list
22-
of the active contexts in the following way::
23+
of the active contexts in the following way:
2324
2425
print driver.contexts
2526

appium/webdriver/common/mobileby.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from selenium.webdriver.common.by import By
1616

17+
1718
class MobileBy(By):
1819
IOS_UIAUTOMATION = '-ios uiautomation'
1920
ANDROID_UIAUTOMATOR = '-android uiautomator'

appium/webdriver/common/multi_action.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
# limitations under the License.
1414

1515

16-
1716
# The Selenium team implemented something like the Multi Action API in the form of
1817
# "action chains" (https://code.google.com/p/selenium/source/browse/py/selenium/webdriver/common/action_chains.py).
1918
# These do not quite work for this situation, and do not allow for ad hoc action
2019
# chaining as the spec requires.
2120

21+
import copy
22+
2223
from appium.webdriver.mobilecommand import MobileCommand as Command
2324

24-
import copy
2525

2626
class MultiAction(object):
2727
def __init__(self, driver, element=None):
@@ -44,7 +44,7 @@ def add(self, *touch_actions):
4444
MultiAction(driver).add(a1, a2)
4545
"""
4646
for touch_action in touch_actions:
47-
if self._touch_actions == None:
47+
if self._touch_actions is None:
4848
self._touch_actions = []
4949

5050
# deep copy, so that once they are in here, the user can't muck about
@@ -68,13 +68,12 @@ def perform(self):
6868

6969
return self
7070

71-
7271
@property
7372
def json_wire_gestures(self):
7473
actions = []
7574
for action in self._touch_actions:
7675
actions.append(action.json_wire_gestures)
77-
if self._element != None:
76+
if self._element is not None:
7877
return {'actions': actions, 'elementId': self._element.id}
7978
else:
8079
return {'actions': actions}

appium/webdriver/common/touch_action.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515

16-
1716
# The Selenium team implemented a version of the Touch Action API in their code
1817
# (https://code.google.com/p/selenium/source/browse/py/selenium/webdriver/common/touch_actions.py)
1918
# but it is deficient in many ways, and does not work in such a way as to be
@@ -22,9 +21,10 @@
2221
#
2322
# Theirs is `TouchActions`. Appium's is `TouchAction`.
2423

24+
import copy
25+
2526
from appium.webdriver.mobilecommand import MobileCommand as Command
2627

27-
import copy
2828

2929
class TouchAction(object):
3030
def __init__(self, driver=None):
@@ -64,11 +64,10 @@ def long_press(self, el=None, x=None, y=None, duration=1000):
6464
def wait(self, ms=0):
6565
"""Pause for `ms` milliseconds.
6666
"""
67-
if ms == None:
67+
if ms is None:
6868
ms = 0
6969

70-
opts = {}
71-
opts['ms'] = ms
70+
opts = {'ms': ms}
7271

7372
self._add_action('wait', opts)
7473

@@ -91,16 +90,14 @@ def release(self):
9190
def perform(self):
9291
"""Perform the action by sending the commands to the server to be operated upon
9392
"""
94-
params = {}
95-
params['actions'] = self._actions
93+
params = {'actions': self._actions}
9694
self._driver.execute(Command.TOUCH_ACTION, params)
9795

9896
# get rid of actions so the object can be reused
9997
self._actions = []
10098

10199
return self
102100

103-
104101
@property
105102
def json_wire_gestures(self):
106103
gestures = []
@@ -109,20 +106,20 @@ def json_wire_gestures(self):
109106
return gestures
110107

111108
def _add_action(self, action, options):
112-
gesture = {}
113-
gesture['action'] = action
114-
gesture['options'] = options
109+
gesture = {
110+
'action': action,
111+
'options': options,
112+
}
115113
self._actions.append(gesture)
116114

117115
def _get_opts(self, element, x, y):
118116
opts = {}
119-
if element != None:
117+
if element is not None:
120118
opts['element'] = element.id
121119

122120
# it makes no sense to have x but no y, or vice versa.
123-
if (x == None) | (y == None):
124-
x = None
125-
y = None
121+
if x is None or y is None:
122+
x, y = None, None
126123
opts['x'] = x
127124
opts['y'] = y
128125

appium/webdriver/errorhandler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from appium.common.exceptions import NoSuchContextException
1919

20+
2021
class MobileErrorHandler(errorhandler.ErrorHandler):
2122
def check_response(self, response):
2223
try:

appium/webdriver/mobilecommand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
1516
class MobileCommand(object):
1617
CONTEXTS = 'getContexts',
1718
GET_CURRENT_CONTEXT = 'getCurrentContext',

appium/webdriver/switch_to.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from .mobilecommand import MobileCommand
1818

19+
1920
class MobileSwitchTo(SwitchTo):
2021
def context(self, context_name):
2122
"""

0 commit comments

Comments
 (0)