java - 如何在 ios 移动应用程序中单击可见 = false 的元素
问题描述
我必须自动化一个 iOS pega 移动应用程序,我有一个需要单击的字段。但是该字段设置为可见的“假”。有没有办法可以点击那个元素?
- 方法(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();
- 方法(2)我使用单击“时钟”图标,即使我使用谓词字符串仍然无法正常工作。
Appium中显示的xpath,
//XCUIElementTypeOther[@name="Center Panel, region"]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[4]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther
解决方案
使用隐藏元素时,您通常希望使用 javascript 与它们进行交互。
在java中,并以您的示例为例,这看起来像
import org.openqa.selenium.JavascriptExecutor; # added to the top of the script
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click()", timeEle);
推荐阅读
- javascript - 查询文档以遍历 Array 并使用 $cond 对 mongodb 中 JSON 的特定属性求和
- swift - 如何一次更改多个标签?- 斯威夫特
- bash - Bash:格式化日期
- css - 无法使用样式化组件和 Next.js 导入 Google 字体
- jquery - 使用 jQuery 在点击事件上添加多个本地存储
- gnupg - 使用通配符的 PGP 脚本
- beautifulsoup - 美丽的汤:如何在 td 中获取时间戳
- python - 在 url 中查找 / 的出现
- tensorflow - 我的损失自定义函数是否像我认为的那样做?
- python - 用于 Java API 的 Python 客户端