首页 > 解决方案 > 如何在 ios 移动应用程序中单击可见 = false 的元素

问题描述

我必须自动化一个 iOS pega 移动应用程序,我有一个需要单击的字段。但是该字段设置为可见的“假”。有没有办法可以点击那个元素?

手机屏幕图片

  1. 方法(1)我使用了点击时间(秒)文本字段,但这设置为可见假

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. 方法(2)我使用单击“时钟”图标,即使我使用谓词字符串仍然无法正常工作。

Appium中显示的xpath,

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

标签: javaiosseleniumautomationappium

解决方案


使用隐藏元素时,您通常希望使用 javascript 与它们进行交互。

在java中,并以您的示例为例,这看起来像

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

推荐阅读