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
2221#
2322# Theirs is `TouchActions`. Appium's is `TouchAction`.
2423
24+ import copy
25+
2526from appium .webdriver .mobilecommand import MobileCommand as Command
2627
27- import copy
2828
2929class 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
0 commit comments