Scaling action in android using appium-python-client

Does anyone know how to increment an element in android via appium python client?

I am currently using

self.driver.zoom(self.element, percent) , but this gives an error

 self.driver.zoom(self.element, percent) File "/usr/local/lib/python2.7/site-packages/appium/webdriver/webdriver.py", line 308, in zoom self.execute_script('mobile: pinchOpen', opts) File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 461, in execute_script {'script': script, 'args':converted_args})['value'] File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 233, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/site-packages/appium/webdriver/errorhandler.py", line 29, in check_response raise wde WebDriverException: Message: Method has not yet been implemented 

I also tried through MultiAction .

 loc = self.element.location print loc xx, yy = loc["x"], loc["y"] xx=700 action1 = TouchAction(self.driver) action1.long_press(x=xx, y=yy).move_to(x=0, y=1000).release() action2 = TouchAction(self.driver) action2.long_press(x=xx, y=yy).move_to(x=0, y=-1000).release() m_action = MultiAction(self.driver) m_action.add(action1, action2) m_action.perform() 

But again, this does not make any increase. Instead, it scrolls the list down. Does anyone have an idea of ​​what's wrong here.

Appium Logs

 [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"element:getLocation","params":{"elementId":"83"}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getLocation [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"x":0,"y":1225}} [debug] [AndroidBootstrap] Received command result from bootstrap [MJSONWP] Responding to client with driver.getLocation() result: {"x":0,"y":1225} [HTTP] <-- GET /wd/hub/session/c1a4d17f-0dc6-4445-bfad-776ec65bddb5/element/83/location 200 26 ms - 88 [HTTP] --> POST /wd/hub/session/c1a4d17f-0dc6-4445-bfad-776ec65bddb5/touch/multi/perform {"sessionId":"c1a4d17f-0dc6-4445-bfad-776ec65bddb5","actions":[[{"action":"longPress","options":{"y":1225,"x":700,"duration":1000}},{"action":"moveTo","options":{"y":1000,"x":0}},{"action":"release","options":{}}],[{"action":"longPress","options":{"y":1225,"x":700,"duration":1000}},{"action":"moveTo","options":{"y":-1000,"x":0}},{"action":"release","options":{}}]]} [MJSONWP] Calling AppiumDriver.performMultiAction() with args: [[[{"action":"longPress","o... [debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"performMultiPointerGesture","params":{"actions":[[{"action":"longPress","time":0.005,"touch":{"y":1225,"x":700,"duration":1000}},{"action":"moveTo","time":0.01,"touch":{"y":2225,"x":700}}],[{"action":"longPress","time":0.005,"touch":{"y":1225,"x":700,"duration":1000}},{"action":"moveTo","time":0.01,"touch":{"y":225,"x":700}}]]}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"performMultiPointerGesture","params":{"actions":[[{"action":"longPress","time":0.005,"touch":{"y":1225,"x":700,"duration":1000}},{"action":"moveTo","time":0.01,"touch":{"y":2225,"x":700}}],[{"action":"longPress","time":0.005,"touch":{"y":1225,"x":700,"duration":1000}},{"action":"moveTo","time":0.01,"touch":{"y":225,"x":700}}]]}} [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: performMultiPointerGesture [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK"} [debug] [AndroidBootstrap] Received command result from bootstrap [MJSONWP] Responding to client with driver.performMultiAction() result: "OK" [HTTP] <-- POST /wd/hub/session/c1a4d17f-0dc6-4445-bfad-776ec65bddb5/touch/multi/perform 200 133 ms - 76 [HTTP] --> DELETE /wd/hub/session/c1a4d17f-0dc6-4445-bfad-776ec65bddb5 {} 
+7
python android zoom appium python-appium
source share
1 answer

The MultiAction attempt looks good, but after a little testing of my mobile phone app on my phone, I was able to get a nice zoom bug by adding 500ms of wait () after moveTo ():

 # Zoom action1.long_press(x=xx, y=yy).move_to(x=0, y=50).wait(500).release() action2.long_press(x=xx, y=yy).move_to(x=0, y=-50).wait(500).release() m_action.add(action1, action2) # Pinch action3.long_press(x=xx, y=yy-50).move_to(x=0, y=50).wait(500).release() action4.long_press(x=xx, y=yy+50).move_to(x=0, y=-50).wait(500).release() m_action2.add(action3, action4) m_action.perform() m_action2.perform() 

This led to a good and slow approach to the camera application. Without waiting (), the gestures were too fast and didn’t really help much. It is mentioned in the Appium documentation on Github that wait () can be used to control the timing of gestures: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/touch-actions.md

I set xx and yy to the middle of the screen in my camera application:

 xx = self.driver.get_window_size()['width']/2 yy = self.driver.get_window_size()['height']/2 

Remember that the coordinates should never go beyond the screen of the device, so checking the borders of the screen can be useful if you want to do this in a reusable function.

I also could not use MultiAction gestures in Chrome automation (even when changing the context of NATIVE_APP. Gestures did not affect it.), So it is possible that using MultiActions in WebView scripts is not supported.

+4
source share

All Articles