Sha256: a8132c4d0024f589c454fc443df41131c8ebf6e797100f19fbe14609bc534415

Contents?: true

Size: 1.5 KB

Versions: 159

Compression:

Stored size: 1.5 KB

Contents

package sh.calaba.instrumentationbackend.actions.button;


import sh.calaba.instrumentationbackend.InstrumentationBackend;
import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.TestHelpers;
import sh.calaba.instrumentationbackend.actions.Action;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;


public class WaitForButton implements Action {

    @Override
    public Result execute(String... args) {
        String text = args[0];
        long endTime = System.currentTimeMillis() + 60000;
        while (System.currentTimeMillis() < endTime) {
            if (InstrumentationBackend.solo.searchButton(text) || searchForButtonWithContentDescription(text)) {
                return Result.successResult();
            } else {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    return Result.fromThrowable(e);
                }
            }
        }
        return new Result(false, "Timed out while waiting for button with text or contentDescription:'" + text + "'");
    }

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

    private boolean searchForButtonWithContentDescription(String description) {
        View view = TestHelpers.getViewByDescription(description);
        if (view != null && (view instanceof Button || view instanceof ImageButton)) {
            return true;
        } else {
            return false;
        }
    }

}

Version data entries

159 entries across 159 versions & 2 rubygems

Version Path
calabash-android-0.4.10.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.10.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.10.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.10.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
testautoa-0.4.5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.9.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.9.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.9.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.9.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java
calabash-android-0.4.7.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/button/WaitForButton.java