如何在 ios 移动应用程序中点击 visible=false 的元素

How to click on an element which is visible=false in an ios mobile app

我必须自动化一个 iOS pega 移动应用程序,我有一个字段需要单击。但是该字段设置为可见 "false"。有什么方法可以让我点击该元素吗?

Image of the mobile screen

  1. 方法(一)我用的 单击时间(秒)文本字段,但它设置为可见 false

String selector = "type=='XCUIElementTypeStaticText' AND rect.x==101 AND rect.y==150 AND(visible == 0 OR enabled == 1)"; MobileElement timeEle = driver.findElementByIosNsPredicate(selector); timeEle.click();

  1. 我用的方法(二) 单击 "Clock" 图标,即使我使用谓词字符串仍然无法正常工作。

Appium 中显示的 xpath,

//XCUIElementTypeOther[@name="Center Panel, region"]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[4]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther

在处理隐藏元素时,您通常会希望使用 java脚本与它们交互。

在 java 中,对于您的示例,这看起来像

import org.openqa.selenium.JavascriptExecutor; # added to the top of the script
JavascriptExecutor js = (JavascriptExecutor) driver;  
js.executeScript("arguments[0].click()", timeEle);