点击webview android上的html按钮

时间:2017-03-30 10:12:45

标签: javascript java android webview

我从服务器上读过json文件,他包含有关html按钮站点的信息:

"apply": {
                "type": "click",
                "submit": "#cart-summary-ecouponForm-button",
                "timeout": 5000
            }
"controls": {
                "promo": "#CouponCode",
                "total": ".cart-summary-pricing-webPrice-price",
                "orderTotal": ".cart-summary-pricingTotal dd",
                "coupon": ".remove"
            }

html代码:

 <input onfocus="this.select(); if(this.value == '') { this.value = '' }" onkeypress="if (wci.cart.checkForEnterPress(event)) {wci.cart.addECoupon('ecouponForm', '//shop.lenovo.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/cart.workflow:add-e-coupon'); return false; }" id="CouponCode" name="CouponCode" type="text" class="iform cart-summary-ecouponForm-field" value="" size="15" maxlength="99" onblur="if(this.value == '') { this.value = '' }" placeholder="ENTER CART COUPON CODE">

<input onclick="return handleCouponPost();" class="button-standard cart-summary-ecouponForm-button" id="cart-summary-ecouponForm-button" type="submit" value="Apply">
    <script>
    function handleCouponPost()
    {
        if("true" == "")
        {
            var whattodo = confirm("WARNING: Applying another offer via eCoupon will remove the free  offer offer from your purchase.\nDo you want to proceed?");
            if(whattodo == true)
            {
              return wci.cart.addECoupon('ecouponForm', '//shop.lenovo.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/cart.workflow:add-e-coupon');
            }
            return false;
        }
        else
        {
            return wci.cart.addECoupon('ecouponForm', '//shop.lenovo.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/cart.workflow:add-e-coupon');
        }
    }
    </script>

&#34;促销&#34;:&#34;#CouponCode&#34; = html中输入文字字段的名称,我需要找到此字段并设置一些自定义值在Android活动中以编程方式运行=&#34;&#34; ,点击按钮&#34;提交&#34;:&#34;#cart-summary-ecouponForm-b​​utton&#34;

我们说我找到按钮&#34;提交&#34;:&#34;#cart-summary-ecouponForm-b​​utton&#34;,然后找到功能名称 handleCouponPost 。我模拟了按钮的点击,但是如何在值参数中替换所需的值?

0 个答案:

没有答案