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

Cannot tap a "toggle" button in WebView #340

Closed
pliablepixels opened this issue Mar 7, 2019 · 2 comments
Closed

Cannot tap a "toggle" button in WebView #340

pliablepixels opened this issue Mar 7, 2019 · 2 comments

Comments

@pliablepixels
Copy link

pliablepixels commented Mar 7, 2019

The problem

I am developing an app using ionic (v1). Ionic has an <ion-toggle> button (that is essentially a glorified checkbox) that I am not able to toggle

Environment

  • Appium version (or git revision) that exhibits the issue: 1.11.1
  • Desktop OS/version used to run Appium: OSX High Sierra
  • Node.js version (unless using Appium.app|exe): 8.11.2
  • Mobile platform/version under test: Android 7.1.1
  • Real device or emulator/simulator: Emulator
  • Appium CLI or Appium.app|exe: appium run via NodeJS

Details

This is the toggle I am trying to click:

screen shot 2019-03-07 at 4 15 33 pm

See code below

My template:

<ion-toggle id="testaut_useauth_toggle" 
            ng-change="toggleAuth()" 
            ng-model="wizard.useauth" 
            toggle-class="toggle-calm">{{'kWizUseAuth' |
          translate}}
</ion-toggle>

Invocation of code in appium test script:

self.tap_item("testaut_useauth_toggle")

1st implementation:

def click_item(self,id, wait=5):
        element = self.driver.find_element_by_id(id)
        element.click()
        sleep(wait)

Output:

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: unknown error: Element <div class="item item-toggle toggle-small ng-not-empty ng-valid" id="testaut_useauth_toggle" ng-change="toggleAuth()" ng-model="wizard.useauth" toggle-class="toggle-calm" style="">...</div> is not clickable at point (180, 190). Other element would receive the click: <section ng-show="selected" ng-class="{current: selected, done: completed}" class="step current" ng-transclude="" wz-title="2" style="">...</section>
  (Session info: chrome=55.0.2883.91)

2nd Implementation:

 def tap_item(self,id,wait=5):
        print ('Tapping item: {}'.format(id))
        element = self.driver.find_element_by_id(id)
        #self.driver.execute_script("arguments[0]).click();", element);
        self.driver.execute_script("document.getElementById(arguments[0]).click();", id);

Output:
No error, but nothing happens

3rd implementation:

def tap_item(self,id,wait=5):
        l = element.location
        s = element.size
        print ("HERE {} & {}".format(l,s))

        factor = float(3.428) # emulator VM reported size / screen size 
        tapX = 286 * factor # I loaded the image in an editor and found the center of the toggle
        tapY = 190 * factor 
        old_context = self.driver.current_context
        self.driver.switch_to.context("NATIVE_APP")
        actions = TouchAction(self.driver)
        print ("TAPPING AT {}:{}".format(str(tapX), str(tapY)))
        actions.tap(None,tapX, tapY,1)
        actions.perform()
        self.driver.switch_to.context(old_context)
        sleep(wait)

Output: nothing happens

@KazuCocoa
Copy link
Member

selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: unknown error: Element

...
is not clickable at point (180, 190). Other element would receive the click:
...

Is this https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error ? (Appium throws commands to chromedriver directly)

If you could try appium@beta, you also can try mobile: webatom feature
https://github.com/appium/appium-espresso-driver/blob/36837a1a8735a7ceaa64711efecd9fd2ec5b66b6/lib/commands/general.js#L99
appium/appium-espresso-driver#380

@pliablepixels
Copy link
Author

pliablepixels commented Mar 8, 2019

Yes, the error is the same as that specific SO thread, but none of the (very diverse) solutions actually worked. That being said, I'm going to close this out as I figured out how to handle this element. I had to get more specific after looking at how the toggle button was implemented and after some experimentation on which sub-element needs to be the target of the click.

Final solution:

def tap_toggle(id,wait=Wait.TOGGLE):
    element = driver.find_element_by_id(id)
    element = element.find_element_by_tag_name('label')
    element.click()
    sleep(wait)

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

2 participants