Handling Alert with UIAutomation

前端 未结 7 1555
日久生厌
日久生厌 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:15

    Make sure the UI Automation script is still running when the UIAlertView shows.

    For example, adding the following line to the end of your script will keep it running until an alert becomes accessible or the grace period for object resolution expires.

    // Wait for UIAlert to appear so that UIATarget.onAlert gets called.
    target.frontMostApp().alert();
    

    I figured this out by thoroughly reading & understanding Instruments User Guide: Automating UI Testing, which I highly recommend doing as an introduction to UI Automation.

    It may also be helpful to review the UIATarget Class Reference, specifically the methods popTimeout, pushTimeout, setTimeout, timeout, and delay.

提交回复
热议问题