facebookarchive / WebDriverAgent

A WebDriver server for iOS that runs inside the Simulator.
Other
4.15k stars 1.37k forks source link

click() not working for some iOS elements (Appium 1.6.5) #602

Closed Brian-Watson closed 7 years ago

Brian-Watson commented 7 years ago

The problem

I have a page in my app that has a XCUIElementTypeTable element on it with a collection of cells. When first launched, the cell I wish to click on is not visible, as it's off screen at the time. So I scroll the table down to make the cell visible. I then find a XCUIElementTypeTextField in the cell, and then try to click() on it. After upgrading to Appium 1.6.5 from 1.6.4, the click() call to WDA returns successfully, but the element isn't really clicked. This worked in the version of WDA that ships with Appium 1.6.4.

Environment

Details

After scrolling an element into view, the click() doesn't seem to actually work. One thing I noticed is that in Appium 1.6.5, I now see a 'visible' attribute being returned in the page source for iOS elements. This attribute comes back as 'false' for the element I'm trying to click, even after it's scrolled into view. Maybe there's some sort of caching going on that the scroll doesn't fully trigger a change for as far as the "visibility" is concerned? The x,y coordinates indeed update when I do a getPageSource() before and after the scroll though.

Link to Appium logs

https://gist.github.com/Brian-Watson/bf6aee5b4652ba8fe4ce560e799e44c1

Code To Reproduce Issue [ Good To Have ]

mobile:scroll down on my XCUIElementTypeTable element

Then click on a XCUIElementTypeTextField, with ID "StateID" that should now be visible.

Link to related Appium issue for this:

https://github.com/appium/appium/issues/8571

ghost commented 7 years ago

Hi there! I do have the same problem with driver.tap(coordinates) Button is tapped and Appium returns 200 code, but nothing happens on the device screen Tap works only if do it by finger

chris-wickens commented 7 years ago

Had the same issue. I've worked around it for now by replacing calls to the click method with the following:

new TouchAction(driver).tap(element).perform();

marekcirkos commented 7 years ago

From what I understand all of you tap with x,y coordinates? I assume this is very consistent for you. Can you provide a failing sample? So that I can investigate it further? We do have tapping tests and they are green so I assume this is some edge case.

ghost commented 7 years ago

I have 2 Appiums actually npm Appium desktop Appium Uninstalled today npm Appium and installed it again, installed appium 1.6.5 and everything works fine as for now.

Brian-Watson commented 7 years ago

@marekcirkos This is a click() action, not a tap(). My initial post I believe describes the scenario the best. If you still need more info, please let me know and I'll try upgrading one of my servers to Appium 1.6.5 to reproduce this again.

KuKiSiNi77 commented 7 years ago

I meet the same problem.is there anyone have some solutions? https://github.com/facebook/WebDriverAgent/issues/656

@Strybushnyi don't the problem have disappeared yet?

plaquette commented 7 years ago

@Brian-Watson i have the same problem, corresponding issue: https://github.com/appium/appium/issues/8771 did you find a solution by now?

@Strybushnyi did i get that right, your issue was only with npm appium - and you never deinstalled the desktop version

ghost commented 7 years ago

@plaquette don't remember the exact steps i've done(seems like I reinstalled both), but as for now i use both npm and desktop appium and have no issues with any actions

plaquette commented 7 years ago

thanks for the note!

for me it works now using the 1.6.6 beta 4

... hope it still works once the final version is shipped

ghost commented 7 years ago

my terminal version is 1.6.5, have no time to uninstall and install it again since it may cause some issues (and npm update does not work for beta) nevertheless, i do update desktop version each time there is a new update

Brian-Watson commented 7 years ago

The only solution I had found was to stay at Appium 1.6.4, and not upgrade to 1.6.5. If I get some free time, I may give Appium 1.6.6 a try to see if it fixes the issue as I was seeing it. Thanks for the heads-up!

plaquette commented 7 years ago

@Brian-Watson you are welcome

yeah, i did the same - although it was very unsatisfying to not be able to upgrad. but still better than click in the fields using coordinates.

but back to topic, after a day+ of testing i can say 1.66 beta 4 is stable regarding the webdriver fixes. it works local and on our server as well

Brian-Watson commented 7 years ago

Yep, verified that my issue is cleared up with the version of the WebDriverAgent that comes bundled with Appium 1.6.6-beta4. Thanks devs, closing the issue!

aryalakshmi commented 6 years ago

I am in 1.8.2 beta and still facing the issue

xtander commented 6 years ago

same issue in 1.8.1

Any2suited66 commented 6 years ago

same issue on 1.9.0

meetravi commented 6 years ago

+1 Same issue on 1.9.1

ashwinibaisutrave commented 6 years ago

Same issue on 1.9.1

mykola-mokhnach commented 6 years ago

https://appiumpro.com/editions/36

ecbarreto commented 5 years ago

@mykola-mokhnach I've tried and still not working.

I'm trying to click on a simple button, I can get the text from the button, but the click is simply not performed.

palashjain71 commented 5 years ago

Hi Does anyone got the resolution for above problem. even I am also not able to click on simple link on Iphone web Safari. My Capabilities are listed below: Appium version 1.7.1

d.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT ,true); d.setCapability("nativeWebTap", true); d.setCapability(MobileCapabilityType.BROWSER_NAME,MobileBrowserType.SAFARI); d.setCapability(MobileCapabilityType.PLATFORM_NAME, "IOS"); d.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.IOS_XCUI_TEST);

batuwka commented 5 years ago

same issue on 1.8.1 and 1.9.1... tried with different combination of caps: nativeWebTap, safariOpenLinksInBackground, safariAllowPopups, safariIgnoreFraudWarning - but unsuccessful. expected behavior - open new tab with context. (desktop browser open the ifame window)

Appium logs

shenyusun commented 5 years ago

Same issue on 1.9.0. I am able to get the text from the element, but not able to click due to the visible attribute value is false.

izanna3004 commented 5 years ago

try to use executeScript("arguments[0].click();", driver.findElement(element)

nihalalfred commented 5 years ago

This is happening for me too. I am using 1.10.1 What I noticed is it works once and then it fails the second time. its quite random. I searched a lot for a solution on this. But no one is able to resolve this.

enihar commented 5 years ago

Same issue. Any solution to this please?

Jayesh2011 commented 5 years ago

@mykola-mokhnach Any update on this issue?

rafaelcs commented 5 years ago

I was with the same issue and using actions worked for me. If you're using Ruby, see it: https://www.rubydoc.info/github/appium/ruby_lib_core/Appium/Core/Base/Bridge/W3C#action-instance_method

swatikalra commented 5 years ago

I am also facing the same issue in the latest appium version. I am using appium with java. Did you find any solution to this? @Brian-Watson

ganjarpanji commented 5 years ago

hi guys, i found a workaround for this. if you attempt to force click the element that has attribute visibile = false you could use this :


public` void tapByElement(AppiumDriver<WebElement> driver, WebElement element) {
        int startX = element.getLocation().getX();
        int addition = (int) (element.getSize().height * 0.5);
        int endX = startX + addition;
        int startY = element.getLocation().getY();
        new TouchAction(driver).tap(point(endX, startY)).perform();
    } 
Brian-Watson commented 5 years ago

My initial problem raised for this was fixed in Appium 1.6.6, so I closed this issue as that was the solution for the issue I raised. Unfortunately, I have since moved onto another project where I'm no longer using Appium, so I have no idea if this issue is indeed back or not.

swatikalra commented 5 years ago

Hi @ganjarpanji we cannot rely on location. Is there any other way around?

ganjarpanji commented 5 years ago

@swatikalra could you elaborate why? im not sure with another approach.

batuwka commented 5 years ago

I've found a solution for my case (using appium 1.10.1, wdio5+,): browser.updateSettings({nativeWebTap: true}); $(selector).click(); browser.updateSettings({nativeWebTap: false});

AndreiRR commented 5 years ago

@ganjarpanji 's solution has worked for me:) Thank you.

Abrahamsf commented 5 years ago

hi guys, i found a workaround for this. if you attempt to force click the element that has attribute visibile = false you could use this :

public` void tapByElement(AppiumDriver<WebElement> driver, WebElement element) {
      int startX = element.getLocation().getX();
      int addition = (int) (element.getSize().height * 0.5);
      int endX = startX + addition;
      int startY = element.getLocation().getY();
      new TouchAction(driver).tap(point(endX, startY)).perform();
  } 

Bit messy but works, thank you.

ghost commented 5 years ago

I am facing same issue when running the tests on iphone simulator. But on react-native app, it is not web app...