简体   繁体   English

Xcode:UI 自动化:waitForValid()

[英]Xcode: UI Automation: waitForValid()

There's a waitForInvalid() but what about a waitForValid() function?有一个 waitForInvalid() 但是 waitForValid() function 呢? For some reason, push/popTimeout doesn't work for me in many cases.出于某种原因,push/popTimeout 在很多情况下对我不起作用。 Apple?苹果?

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();

When you try to access a particular element directly, there is a default wait time of 5 seconds.当您尝试直接访问特定元素时,默认等待时间为 5 秒。 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."这将使您的仪器最多等待 20 秒,直到导航栏的名称更改为“欢迎”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM