Android Question Clicking a "class" button in a webview?

kostefar

Active Member
Licensed User
Longtime User
Dear All,

I understand how to programatically click a simple button such as:

B4X:
    Dim Javascript As StringBuilder
    Javascript.Initialize
    Javascript.Append("var form=document.forms[0];") 
    Javascript.Append("form.button_login.click()")
    Dim WebViewExtras1 As WebViewExtras
    WebViewExtras1.executeJavascript(webview1, Javascript.ToString)

But how about if you would want to click something like this:

B4X:
<button type="button" class="js-sell-btn tst-sell-btn btn btn--sell">Sell</button>

Thanks in advance!

Ok, been playing around a bit.. figured out that if I put Javascript.Append("form.js-sell-btn.click()"), it actually works! That was just a random shot in the dark, and not sure why this did it.. any comments on that? I tried with the full class name as well as btn--sell, but got on response.
 
Last edited:
Top