【问题标题】:How to click on an element which is visible=false in an ios mobile app如何在 ios 移动应用程序中单击可见 = false 的元素
【发布时间】:2020-06-04 06:19:29
【问题描述】:

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

Image of the mobile screen

  1. 方法(1)我用过 单击 Time(secs) 文本字段,但这设置为可见 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. 方法(2)我使用 单击“时钟”图标,即使我使用谓词字符串仍然无法正常工作。

Appium 中显示的 xpath,

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

【问题讨论】:

    标签: java ios selenium automation appium


    【解决方案1】:

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

    在 java 中,在你的例子中,这看起来像

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

    【讨论】:

    • 问题是我找不到要点击的元素。它给了我一个错误,说“得到了状态 404 的意外响应:{“value”:{“error”:“no such element”,“message”:“unable to find an element using 'predicate string', value 'type =='XCUIElementTypeTextField' AND rect.x==25 AND rect.y==164 AND(visible == 0 OR enabled == 1)'"
    • 您是否可以使用检查器来检查元素标签、类、名称或其他内容以识别它?
    • 是的,我正在从 appium 检查它。
    猜你喜欢
    • 2017-05-06
    • 2022-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    • 1970-01-01
    相关资源
    最近更新 更多