Sha256: 957ffb3ce03ed84bc9b54be9a453a0cc0735448cbed7039b248200dab540b7ab

Contents?: true

Size: 1.71 KB

Versions: 40

Compression:

Stored size: 1.71 KB

Contents

package sh.calaba.instrumentationbackend.actions.view;


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;


/*
 * Warning: Unlike most other actions this action will allow you to click on views that are not visible.
 */
public class ClickOnViewById implements Action {

    @Override
    public Result execute(String... args) {
        final View view = TestHelpers.getViewById(args[0]);

        if(view == null) {
            return new Result(false, "Could not find view with id: '" + args[0] + "'");
        }
		try {
			System.out.println("Clicking on view: " + view.getClass());
			System.out.println(view.getLeft());
			System.out.println(view.getTop());
			System.out.println(view.getWidth());
			System.out.println(view.getHeight());
			int[] xy = new int[2];

			view.getLocationOnScreen(xy);
			System.out.println(xy[0]);
			System.out.println(xy[1]);
			
			//InstrumentationBackend.solo.clickOnView(view);		
			if (view.isClickable()) {
				InstrumentationBackend.solo.getCurrentActivity().runOnUiThread(new Runnable() {
					public void run() {
						view.performClick();
					}	
				});
			}
		} catch(junit.framework.AssertionFailedError e) {
			System.out.println("solo.clickOnView failed - using fallback");
			if (view.isClickable()) {
				InstrumentationBackend.solo.getCurrentActivity().runOnUiThread(new Runnable() {
					public void run() {
						view.performClick();
					}	
				});
			}
		}
        return Result.successResult();
    }

    @Override
    public String key() {
        return "click_on_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/ClickOnViewById.java
calabash-android-0.2.10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
calabash-android-0.2.0.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java