Handling Alert with UIAutomation

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

    The documentation seems to be wrong. It turns out that alerts are handled on the same thread your script tries to run. So if you want the alert handler to be called, you need to sleep, e.g.,

    UIATarget.onAlert = { ... }
    window.buttons().triggerAlertButton.tap();
    UIATarget.localTarget().delay(4);
    

    Also, it appears that the alert's name and value are always set to null. I was, however, able to access the first static text which contained the alert's title.

提交回复
热议问题