我想在一個循環內使用isVisible()來爲我的iOS UIAutomation創建一個函數的waitForElement類型。當我嘗試使用下面的代碼時,彈出一個新屏幕時等待一個元素失敗。該元素顯然存在,因爲如果我在點擊元素之前做了延遲(2),它的工作效果就很好。如何其他人完成這一點,因爲我很茫然......iOS UIAutomation UIAElement.isVisible()拋出陳舊的響應?
下面是我使用的代碼waitForElement:
function waitForElement(element, timeout, step) {
if (step == null) {
step = 0.5;
}
if (timeout == null) {
timeout = 10;
}
var stop = timeout/step;
for (var i = 0; i < stop; i++) {
if (element.isVisible()) {
return;
}
target.delay(step);
}
element.logElement();
throw("Not visible");
}
你最終解決了這個問題嗎?我正在尋找類似的東西。 – Stew