Xcode: UI Automation: waitForValid()

一世执手 提交于 2020-02-20 06:00:06

问题


There's a waitForInvalid() but what about a waitForValid() function? For some reason, push/popTimeout doesn't work for me in many cases. Apple?


回答1:


If the element is "valid" but not "visible" that might return too early. This should wait until its visible and valid.

UIATarget.localTarget().pushTimeout(20);
window.navigationBar().name()["Welcome"].withValueForKey(1, "isVisible");
UIATarget.localTarget().popTimeout();

or

UIATarget.localTarget().pushTimeout(20);
window.navigationBar().name().firstWithPredicate("name is 'Welcome' and isVisible == '1'")
UIATarget.localTarget().popTimeout();



回答2:


When you try to access a particular element directly, there is a default wait time of 5 seconds. You can change the default time as follows.

UIATarget.localTarget().pushTimeout(20);
window.navigationBar().name()["Welcome"];
UIATarget.localTarget().popTimeout();

This will make your instruments wait up to 20 seconds until the name of the navigation bar has changed to "Welcome."



来源:https://stackoverflow.com/questions/6350925/xcode-ui-automation-waitforvalid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!