我有这个代码如何点击c#
问题1
<button onclick="SearchProducts(true);" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">
<i class="fa fa-search"></i>
Zoeken
</span></button>
webBrowser2.Document.InvokeScript(&#34; searchbox&#34;,new object [] {true});这项工作
问题2
我有这个代码如何点击c#
<div class="searchbox" ng-click="doSubmit($event)">
<div class="input-container">
<form ng-submit="doSubmit($event)" class="ng-pristine ng-valid ng-valid-maxlength">
<input type="text" maxlength="100" class="searchboxfield ng-pristine ng-untouched ng-valid ng-valid-maxlength" name="searchboxfield" data-test="searchboxfield" ng-model="searchterm" placeholder="Zoek op EAN, titel of referentiecode">
</form>
</div>
</div>
答案 0 :(得分:0)
您应该将其作为
调用webBrowser1.Document.InvokeScript("SearchProducts",new object[] { true });
这是一个有效的测试案例。
string html = @"<button onclick='SearchProducts(true);'>
<script>
function SearchProducts(bool){ alert(bool); }
</script>";
webBrowser1.DocumentCompleted += (s, e) =>
{
webBrowser1.Document.InvokeScript("SearchProducts",new object[] { true });
};
webBrowser1.DocumentText = html;