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

TouchAction - would be great if tap or press could support an x,y only (no element) scenario #73

Closed
kiminoa opened this issue Mar 23, 2015 · 4 comments

Comments

@kiminoa
Copy link

kiminoa commented Mar 23, 2015

In trying to dismiss the soft keyboard after a .clear() without resetting the session's keyboard setting (i.e. hide_keyboard is a no go), I thought I'd be clever and use TouchAction like this to tap just outside of the element that had displayed the soft keyboard:

def dismiss_keyboard(element):
    elem_x = element.location['x']
    elem_y = element.location['y']
    # Find average x-value between left edge of app and left edge of element 
    benign_x = (elem_x - 0) / 2                                           

    # Tap between element and edge of app to dismiss soft keyboard          
    action = TouchAction(self.driver)                                       
    action.move_to(                                                         
        benign_x, elem_y).press(                                          
            x=benign_x, y=elem_y).release().perform()   

But, of course, not clever, because both press() and tap() require an element:

Traceback (most recent call last):
  File "/Users/kraymoure/repos/r64/qa/tests/mobile/test_ios_environments.py", line 53, in setUp
    self.clear_search()
  File "/Users/kraymoure/repos/r64/qa/tests/mobile/ios_base.py", line 272, in clear_search
    self.dismiss_soft_keyboard(search_input)
  File "/Users/kraymoure/repos/r64/qa/tests/mobile/ios_base.py", line 295, in dismiss_soft_keyboard
    benign_x, search_y).press(
  File "/Library/Python/2.7/site-packages/appium/webdriver/common/touch_action.py", line 79, in move_to
    self._add_action('moveTo', self._get_opts(el, x, y))
  File "/Library/Python/2.7/site-packages/appium/webdriver/common/touch_action.py", line 118, in _get_opts
    opts['element'] = element.id
AttributeError: 'int' object has no attribute 'id'
@radialmodule
Copy link

TouchAction already supports supplying None for the element (and other arguments).

E.g.: action.press(el=None, x=None, y=None)

@Akulavenkatesh
Copy link
Contributor

can you check if this works:
self.driver.tap([(128.90625, 335.90625 )])
give the co ordinates of the space outside of the element

@earendil
Copy link

Why is this still open!? :D

@KazuCocoa
Copy link
Member

thanks for the notice :)

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

No branches or pull requests

5 participants