[UWP]查找按钮和调用 [英] [UWP]Find button and Invoke
问题描述
我正在使用WebView控件。我可以使用以下脚本识别并填写两个文本控件,用户名和密码:
string usernameString = String.Format(" ; document.getElementById('username')。innerText ='{0}'",@" rbamouser \\\\ comrr");
$
等待WebViewControl.InvokeScriptAsync(" eval", new string [] {usernameString});
但是我无法找到"按钮"按钮。控制此页面并调用它:button tabindex =" 3" class =" c-btn c-btn-secondary c-btn-full-width c-btn-large"
可能有人帮助我
$
您好HerbertRöösli,
您可以使用
HTML DOM getElementsByClassName()方法获取所有按钮并通过您自己的代码逻辑获取特定按钮。然后,您可以调用其click()方法来触发其click事件。string jsString = @" document.getElementsByClassName('c-btn c- btn-secondary c-btn-full-width c-btn-large')[0] .click();" ;;
等待webview.InvokeScriptAsync(" eval",new string [] {jsString});此外,请阅读粘贴帖子,尤其是
发布指南:主题行标签和
Windows 10 SDK和工具的已知问题 请记得添加标签到下次自己打个招呼。
最好的问候,
Xavier Eoro
I'm using the WebView control. It's possible for me to indentify and fill in two text controls, username and password with the following script:
string usernameString = String.Format("document.getElementById('username').innerText = '{0}'", @"rbamouser\\scomr");
await WebViewControl.InvokeScriptAsync("eval", new string[] { usernameString });
But I'm not able to find a "Button" control on this page and invoke it: button tabindex="3" class="c-btn c-btn-secondary c-btn-full-width c-btn-large "/button
May someone help me
Hi Herbert Röösli,
You could use the HTML DOM getElementsByClassName() Method to get all buttons and get the specific button by your own code logic. Then, you could call its click() method to trigger its click event.
string jsString = @"document.getElementsByClassName('c-btn c-btn-secondary c-btn-full-width c-btn-large')[0].click();"; await webview.InvokeScriptAsync("eval", new string[] { jsString });In addition, Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools and please remember to add tag to title by yourself next time.
Best Regards,
Xavier Eoro
这篇关于[UWP]查找按钮和调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!