Sha256: 1058195094a487e79a2fdca9617cfcf26d640115499671dcaab9cf82736178ef

Contents?: true

Size: 1.63 KB

Versions: 40

Compression:

Stored size: 1.63 KB

Contents

package sh.calaba.instrumentationbackend.actions.webview;


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


public class SetPropertyByCssSelector implements Action {

    @Override
    public Result execute(String... args) {
    	String cssSelector = args[0];
    	String propertyName = args[1];
    	String value = args[2];
    	                         
    	for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
    		final WebView webView = ccc.getWebView();
			
    		final String assignment = "document.querySelector(\"" + cssSelector + "\")." + propertyName + " = " + value + ";";
    		System.out.println(assignment);

            InstrumentationBackend.solo.getCurrentActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {

                    webView.loadUrl("javascript:(function() {" +
                               assignment +
                               "prompt('calabash:true');" +
                               "})()");

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

       return new Result(false,"No WebView found");
   }

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

}

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
calabash-android-0.3.3.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.3.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.3.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.2.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.2.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.2.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.2.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.2.pre1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.1 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre10 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre9 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre8 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre7 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre6 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre5 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre4 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre3 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java
calabash-android-0.3.0.pre2 test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java