简体   繁体   中英

On IOS, element is “visible” and being clicked even though it is not displayed

I'm having an issue while running a selenium test on BrowserStack. This test should fail. It does fail on Android but pass on iOS and I just don't understand how.

I'm not allowed to share the html code unfortunately, but I can share my code. I'm calling this method:

public void clickElement() {
        driver.findElement(Element1).click();
    }

Basically, I'm trying to click on a hidden button on mobile. So this test should fail. On Android, my test fails as expected. Button is not displayed so everything is fine.

But on iOS (all devices I could find on BrowserStack, mobile and Tablette alike), this button, yet hidden, is clicked anyway.

I don't understand how this is possible. Does anyone know where this issue come from? Is it related to iOS or BrowserStack? Or both?

Any help would be much appreciated Thanks

There can be 2 reasons here:

  1. The opacity is set to 0 - If this is the case the element might not be visible to us but it is still not hidden. Only if elements are hidden would stop receiving the UITouch events.

  2. There can be views behind the views - So if you hid first one and the other views are behind this first one, they would still keep responding to the UITouch events.

So to ensure what is happening in your case, you must make sure that waitForVisibilityOf method is actually hiding the views for iOS as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM