Search code examples
c#winformswebview2execute-script

Webview2 ExecuteScriptAsync to click an Input button


Please see below this html code for understand:

<input type="submit" name="send" class="button" value="Send" onclick="return ussd_send()">
<input type="submit" name="send" class="button" value="Disconnect" onclick="return ussd_exit()">

I want to click the Send Button, but the code I'm using doesn't have any effect:

webView21.ExecuteScriptAsync("document.getElementsByClassName('return ussd_send()').click();");

Solution

  • webView21.ExecuteScriptAsync("document.getElementsByName('send')[0].click();");
    

    This working for my problem & this give me answer poul bak.

    Poul Bak good man & you can use for your purpose like this issue if you face.