无法自动操作;点击确定按钮;UIAutomation

Unable to automate "click on OK button" with UIAutomation

本文关键字:按钮 UIAutomation 操作      更新时间:2023-09-26

这是3d视图,UIHieracrchy如下

APP -> UIWindow -> UILayoutContainerView -> UINavigationTransitionView -> UIViewControllerWrapperView->UIView->UIButton 

(UIButton in detail)

UIButton -> UIImageView -> MyButton ->UIButtonLabel

所以我尝试了以下

  1. UIATarget.onAlert = function onAlert(alert)
    {
        var title = alert.name();
        if(title == "Failed" || title == "Warning")
        {
            target.delay(5);  
            alert.buttons()["OK"].tap();
            return true;
        }
        UIALogger.logPass("Sign In Failed");
        return false;
    }
    
  2. target.frontMostApp().mainWindow().buttons()["OK"].tap();

  3. target.frontMostApp().mainWindow().buttons()[0].tap();

请帮我解决这个自动按钮的问题。

看起来您已经注释掉了实际取消警告的那一行:

    //alert.buttons()["OK"].tap();

这意味着UIAutomation无法到达按钮——警报仍然阻止它。

在某些情况下,也有一个错误,警告弹出会改变target的值,你必须重新初始化它