简体   繁体   English

在 IOS 上,元素是“可见的”并被点击,即使它没有显示

[英]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.我在 BrowserStack 上运行 selenium 测试时遇到问题。 This test should fail.这个测试应该会失败。 It does fail on Android but pass on iOS and I just don't understand how.它在 Android 上确实失败了,但在 iOS 上通过了,我只是不明白是怎么回事。

I'm not allowed to share the html code unfortunately, but I can share my code.不幸的是,我不允许共享 html 代码,但我可以共享我的代码。 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.在 Android 上,我的测试按预期失败。 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.但是在 iOS 上(我可以在 BrowserStack、移动设备和平板电脑上找到的所有设备),这个按钮虽然隐藏,但无论如何都会被点击。

I don't understand how this is possible.我不明白这怎么可能。 Does anyone know where this issue come from?有谁知道这个问题从何而来? Is it related to iOS or BrowserStack?它与iOS或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.不透明度设置为 0 - 如果是这种情况,元素可能对我们不可见,但仍然没有隐藏。 Only if elements are hidden would stop receiving the UITouch events.只有当元素被隐藏时才会停止接收 UITouch 事件。

  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.视图后面可能有视图 - 因此,如果您隐藏第一个视图而其他视图在第一个视图后面,它们仍将继续响应 UITouch 事件。

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.因此,为了确保在您的情况下发生了什么,您必须确保waitForVisibilityOf方法实际上也隐藏了 iOS 的视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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