iOS UIAutomation UIAActivityIndi​​cator

发布于 2024-11-25 07:12:24 字数 206 浏览 2 评论 0原文

加载内容时,我的根表视图上有一个活动指示器。我正在尝试测试指示器是否存在,但似乎无法获取 UIAActivityIndi​​cator,也无法在应用程序元素树层次结构中的任何位置找到它。该指示器是根表视图的子视图,因此我希望它被视为该元素树的一部分,但我在任何地方都看不到它(除了屏幕上的物理位置)。

从 javascript 获取活动指示器还需要其他魔法吗?

埃德

I've got an activity indicator on my root table view while things get loaded. I'm trying to test for the presence of the indicator, but can't seem to get ahold of the UIAActivityIndicator, nor can I find it anywhere in the app element tree hierarchy. The indicator is a subview of the root table view, so I'd expect it to be seen as a part of that element tree, but I don't see it anywhere (other than physically on the screen).

Any other magic required to grab an activity indicator from javascript?

Ed

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

回忆凄美了谁 2024-12-02 07:12:24

这是我为在 iOS 中等待页面加载而构建的函数。您可以在函数代码执行之前传递一个可选的 preDelay,但它会等待 ActivityIndi​​cator 对象变为 null 30 秒(每半秒尝试一次,共 60 次)。我已经扩展了 UIAutomation 工具,以便在点击对象时包含此命令。

this.wait_for_page_load = function(preDelay) {        
    if (!preDelay) {
        target.delay(0);
    }
    else {
        target.delay(preDelay);
    }

    var done = false;
    var counter = 0;      
    while ((!done) && (counter < 60)) {
        var progressIndicator = UIATarget.localTarget().frontMostApp().windows()[0].activityIndicators()[0];
        if (progressIndicator != "[object UIAElementNil]") {
            target.delay(0.5);
            counter++;  
        }
        else {
            done = true;           
        }
    }
    target.delay(0.5);
}

This is the function I've built for waiting for page loads in iOS. You can pass an optional preDelay before the function's code executes, other than that it waits for the activityIndicator object to become null for 30 seconds (trying every half second, 60 times). I've extended the UIAutomation tool to encompass this command when I tap on objects.

this.wait_for_page_load = function(preDelay) {        
    if (!preDelay) {
        target.delay(0);
    }
    else {
        target.delay(preDelay);
    }

    var done = false;
    var counter = 0;      
    while ((!done) && (counter < 60)) {
        var progressIndicator = UIATarget.localTarget().frontMostApp().windows()[0].activityIndicators()[0];
        if (progressIndicator != "[object UIAElementNil]") {
            target.delay(0.5);
            counter++;  
        }
        else {
            done = true;           
        }
    }
    target.delay(0.5);
}
小猫一只 2024-12-02 07:12:24
target.delay(1);

target.pushTimeout(10);

target.frontMostApp().mainWindow().activityIndicators()["In progress"].waitForInvalid() == true;

target.popTimeout();

这将等待 1 秒以便活动指示器出现。然后,它将等待其失效,超时值为 10 秒。将“进行中”替换为您的指标名称。

target.delay(1);

target.pushTimeout(10);

target.frontMostApp().mainWindow().activityIndicators()["In progress"].waitForInvalid() == true;

target.popTimeout();

This will wait 1 second for activity indicator to appear. Then, it will wait for it to become invalid with a timeout value of 10 seconds. Substitute "In progress" for your indicator name.

梦言归人 2024-12-02 07:12:24

下面的代码行解决了我的问题,

while(target.frontMostApp().mainWindow().activityIndicators()["In progress"].isEnabled());

它等待活动指示器变为禁用(但在指示器从我们的视图中删除后,需要 1-2 秒才能变为禁用)

The below line of code solved my problem

while(target.frontMostApp().mainWindow().activityIndicators()["In progress"].isEnabled());

its wait until the activity indicator become disable(but its take 1-2 more seconds to become disable after indicator removed from our view)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文