Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion appium/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@

from selenium.common.exceptions import InvalidSwitchToTargetException


class NoSuchContextException(InvalidSwitchToTargetException):
"""
Thrown when context target to be switched doesn't exist.

To find the current set of active contexts, you can get a list
of the active contexts in the following way::
of the active contexts in the following way:

print driver.contexts

Expand Down
1 change: 1 addition & 0 deletions appium/webdriver/common/mobileby.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from selenium.webdriver.common.by import By


class MobileBy(By):
IOS_UIAUTOMATION = '-ios uiautomation'
ANDROID_UIAUTOMATOR = '-android uiautomator'
Expand Down
9 changes: 4 additions & 5 deletions appium/webdriver/common/multi_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
# limitations under the License.



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

import copy

from appium.webdriver.mobilecommand import MobileCommand as Command

import copy

class MultiAction(object):
def __init__(self, driver, element=None):
Expand All @@ -44,7 +44,7 @@ def add(self, *touch_actions):
MultiAction(driver).add(a1, a2)
"""
for touch_action in touch_actions:
if self._touch_actions == None:
if self._touch_actions is None:
self._touch_actions = []

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

return self


@property
def json_wire_gestures(self):
actions = []
for action in self._touch_actions:
actions.append(action.json_wire_gestures)
if self._element != None:
if self._element is not None:
return {'actions': actions, 'elementId': self._element.id}
else:
return {'actions': actions}
27 changes: 12 additions & 15 deletions appium/webdriver/common/touch_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.



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

import copy

from appium.webdriver.mobilecommand import MobileCommand as Command

import copy

class TouchAction(object):
def __init__(self, driver=None):
Expand Down Expand Up @@ -64,11 +64,10 @@ def long_press(self, el=None, x=None, y=None, duration=1000):
def wait(self, ms=0):
"""Pause for `ms` milliseconds.
"""
if ms == None:
if ms is None:
ms = 0

opts = {}
opts['ms'] = ms
opts = {'ms': ms}

self._add_action('wait', opts)

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

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

return self


@property
def json_wire_gestures(self):
gestures = []
Expand All @@ -109,20 +106,20 @@ def json_wire_gestures(self):
return gestures

def _add_action(self, action, options):
gesture = {}
gesture['action'] = action
gesture['options'] = options
gesture = {
'action': action,
'options': options,
}
self._actions.append(gesture)

def _get_opts(self, element, x, y):
opts = {}
if element != None:
if element is not None:
opts['element'] = element.id

# it makes no sense to have x but no y, or vice versa.
if (x == None) | (y == None):
x = None
y = None
if x is None or y is None:
x, y = None, None
opts['x'] = x
opts['y'] = y

Expand Down
1 change: 1 addition & 0 deletions appium/webdriver/errorhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from appium.common.exceptions import NoSuchContextException


class MobileErrorHandler(errorhandler.ErrorHandler):
def check_response(self, response):
try:
Expand Down
1 change: 1 addition & 0 deletions appium/webdriver/mobilecommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.


class MobileCommand(object):
CONTEXTS = 'getContexts',
GET_CURRENT_CONTEXT = 'getCurrentContext',
Expand Down
1 change: 1 addition & 0 deletions appium/webdriver/switch_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from .mobilecommand import MobileCommand


class MobileSwitchTo(SwitchTo):
def context(self, context_name):
"""
Expand Down
Loading