Sha256: 43f21a24b402388ca7ad862fa4db268c9a78e3ec766d0dfb47aecfb83d6b6cbc

Contents?: true

Size: 1.22 KB

Versions: 32

Compression:

Stored size: 1.22 KB

Contents

package sh.calaba.instrumentationbackend.actions.webview;


import sh.calaba.instrumentationbackend.Result;
import sh.calaba.instrumentationbackend.TestHelpers;
import sh.calaba.instrumentationbackend.actions.Action;
import android.webkit.WebView;


public class PressByCssSelector implements Action {

    @Override
    public Result execute(String... args) {
    	for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
    		WebView webView = ccc.getWebView();
			
			webView.loadUrl("javascript:(function() {" +
				"var element = document.querySelector(\"" + args[0] + "\");" +
				"if (element != null) {" +
				"	var oEvent = document.createEvent ('MouseEvent');" + 
				"	oEvent.initMouseEvent('click', true, true,window, 1, 1, 1, 1, 1, false, false, false, false, 0, element);" +
				"	element.dispatchEvent( oEvent );" +
				"	prompt('calabash:true');" +
				"}" +
				"prompt('calabash:false');" + 
				"})()");

			String r = ccc.getResult();
			System.out.println("clickOnSelector: " + r);
			if ("true".equals(r)) {
				TestHelpers.wait(0.3);
				return Result.successResult();
			}	
		}
		return new Result(false, "");
    }

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

}

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
calabash-android-0.2.3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.2.0.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.1.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.0.19 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.0.18 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.0.17 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.0.16 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.0.15 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java
calabash-android-0.0.14 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java