Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support touch actions that don't start with press #171

Closed
tiagoshibata opened this issue Jul 20, 2016 · 1 comment · Fixed by #174
Closed

Support touch actions that don't start with press #171

tiagoshibata opened this issue Jul 20, 2016 · 1 comment · Fixed by #174

Comments

@tiagoshibata
Copy link
Contributor

Hi all! I have one more request for a fix on touch actions.

The problem

For some specific tests I'd like to be able to start a drag action and then zoom in the screen (start with a single finger and later touch another finger). The following Python code exemplifies my desired behavior:

#!/usr/bin/env python3
import appium
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction

capabilities = {
    'appActivity': "<activity>",
    'appPackage': "<package>",
    'deviceName': "Android",
    'platformName': "Android",
    'noReset': False
}

webdriver = appium.webdriver.Remote("http://localhost:4723/wd/hub", capabilities)
try:
    contact_1 = TouchAction(webdriver).press(x=14, y=14).wait(5).move_to(x=5, y=-5).release()
    contact_2 = TouchAction(webdriver).wait(5).press(x=24, y=24).wait(5).move_to(x=0, y=4).release()
    multi_touch = MultiAction(webdriver)
    multi_touch.add(contact_1)
    multi_touch.add(contact_2)
    multi_touch.perform()
finally:
    webdriver.quit()

However, Appium crashes when the touch action doesn't start with a press checking the yet undefined x/y coordinates. In the example above, it crashes on the second contact, which starts with wait.

Environment

  • Appium version (or git revision) that exhibits the issue: e026a14141230416e945fb6b49883b9993833f31
  • Desktop OS/version used to run Appium: Linux
  • Node.js version: v6.3.0
  • Mobile platform/version under test: Android
  • Real device
  • Appium CLI

Link to Appium logs

Here, relevant parts:

[HTTP] --> POST /wd/hub/session/52783d80-5081-4bcc-8c45-4b8ca858a159/touch/multi/perform {"sessionId":"52783d80-5081-4bcc-8c45-4b8ca858a159","actions":[[{"action":"press","options":{"x":14,"y":14}},{"action":"moveTo","options":{"x":5,"y":-5}},{"action":"release","options":{}}],[{"action":"wait","options":{"ms":5}},{"action":"press","options":{"x":24,"y":24}},{"action":"moveTo","options":{"x":0,"y":4}},{"action":"release","options":{}}]]}
[MJSONWP] Calling AppiumDriver.performMultiAction() with args: [[[{"action":"press","optio...
[MJSONWP] Encountered internal error running command: TypeError: Cannot read property 'x' of null
    at AndroidDriver.callee$0$0$ (lib/commands/touch.js:258:32)
    at tryCatch (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/home/tiago/code/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)

Code To Reproduce Issue

Given above.


Could some of you provide a fix? I might try to get a PR done if you guys are busy with other issues.

Thanks!

@tiagoshibata
Copy link
Contributor Author

tiagoshibata commented Jul 26, 2016

Seems easy to fix, I will get a PR with tests against this bug and a fix done tomorrow.

tiagoshibata added a commit to tiagoshibata/appium-android-driver that referenced this issue Jul 27, 2016
tiagoshibata added a commit to tiagoshibata/appium-android-driver that referenced this issue Aug 9, 2016
tiagoshibata added a commit to tiagoshibata/appium-android-driver that referenced this issue Aug 9, 2016
tiagoshibata added a commit to tiagoshibata/appium-android-bootstrap that referenced this issue Aug 14, 2016
Support touch actions starting and ending at different moments
imurchie added a commit to appium-boneyard/appium-android-bootstrap that referenced this issue Aug 23, 2016
tiagoshibata added a commit to tiagoshibata/appium-android-driver that referenced this issue Aug 24, 2016
imurchie added a commit that referenced this issue Aug 24, 2016
Fixes #171, removes unused state.touch parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant