Sha256: bc1b96bc0a6f0912df41452770b9990e5b3586fb6f6283e7790faba5568ac267

Contents?: true

Size: 1.45 KB

Versions: 40

Compression:

Stored size: 1.45 KB

Contents

package sh.calaba.instrumentationbackend.actions.view;


import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.TestHelpers;
import sh.calaba.instrumentationbackend.actions.Action;
import android.view.View;


public class WaitForViewById implements Action {

    @Override
    public Result execute(String... args) {
        String viewId = args[0];
        System.out.println("Waiting for view with id '" + viewId + "'");
        long endTime = System.currentTimeMillis() + 60000;
        while (System.currentTimeMillis() < endTime) {
            View view = TestHelpers.getViewById(viewId);
            System.out.println("Waiting for view with id '" + viewId + "' found view " + view);

            if (view != null) {
                System.out.println("Waiting for view with id '" + viewId + "' Success");
                return Result.successResult();
            } else {
                try {
                    System.out.println("Waiting for view with id '" + viewId + "' sleeping...");
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    return Result.fromThrowable(e);
                }
            }
        }
        System.out.println("Waiting for view with id '" + viewId + "' Timed out");
        return new Result(false, "Timed out while waiting for view with id:'" + viewId + "'");
    }

    @Override
    public String key() {
        return "wait_for_view_by_id";
    }
}

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
calabash-android-0.2.0.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.1.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.19 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.17 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.15 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.14 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.13 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.12 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.11 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.0.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java