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.11 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java
calabash-android-0.2.0.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForViewById.java