c# - invoke click on a buton in UWP webview on HTML DOM without an id -


i have c# uwp app , want click button html dom shown below using webview.

<button type="button" class="btn btn-primary btn-extra-pad btn-shadow" onclick="checkmsgshowbig()">send</button> 

normally input has id, , code below trick

var functionstring = string.format(@"document.getelementbyid('id').click();"); await webview.invokescriptasync("eval", new string[] { functionstring }); 

but button has class name. code below should work when using class name, not work.

var functionstring = string.format(@"document.getelementsbyclassname('id').click();"); await webview.invokescriptasync("eval", new string[] { functionstring }); 

how make work? thank you.

the return value getelementsbyclassname array should index before using it.

here code sample

private async void simulateclickasync() {     var functionstring = string.format(@"document.getelementsbyclassname('btn btn-primary btn-extra-pad btn-shadow')[0].click();");     await webview.invokescriptasync("eval", new string[] { functionstring }); } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -