Handling Alert with UIAutomation

前端 未结 7 1509
日久生厌
日久生厌 2020-12-31 07:14

I\'m trying to test the presence of an UIAlertView with UIAutomation but my handler never gets called.

At the beginning of my javascript i write :

UI         


        
7条回答
  •  离开以前
    2020-12-31 07:39

    The below code works for me. The function is handling the alert and "alert Shown" is printed on the logs.

    var target = UIATarget.localTarget();
    var application = target.frontMostApp();
    var window = application.mainWindow();
    
    UIATarget.onAlert = function onAlert(alert){
        UIALogger.logMessage("alert Shown");    
    }
    
    target.frontMostApp().mainWindow().tableViews()[0]
        .cells()["Fhgui"].buttons()["Images"].tap();
    // Alert detected. Expressions for handling alerts 
    // should be moved into the UIATarget.onAlert function definition.
    target.frontMostApp().alert().defaultButton().tap();
    

提交回复
热议问题