我填写了一个网站以登录并输入号码。多数民众赞成在似乎工作,但我不能以某种方式执行事件按钮。也许很简单,但是我无法从.NET中的代码中单击它。
在.NET
Web.Document.GetElementById("hwbOrPiece").InnerText = txtCID.Text
Web.Document.InvokeScript("query()")
网站
<button class="md-icon-button md-button md-ink-ripple" type="button"
ng-transclude="" aria-label="Search" ng-click="query()">
<i class="material-icons md-24 ng-scope">search</i>
</button>
<button class="md-icon-button md-button md-ink-ripple" type="button"
ng-transclude="" aria-label="Search" ng-click="query()">
<i class="material-icons md-24 ng-scope">search</i>
</button>
输入字段“ hwbOrPiece”有效,我看到了该值。手动地,我按下搜索按钮,我得到了结果。但是,当然,我想使其自动化。所以我希望事件'query()'在我的代码中执行。
一些帮助会很棒!
亲切的问候, 克里斯
答案 0 :(得分:0)
(当然)尝试并查看了很多信息之后,我可以触发按钮:
Dim HtmlElementcol As HtmlElementCollection = Web.Document.GetElementsByTagName("button")
For Each ele As HtmlElement In HtmlElementcol
'Check the attributtes you want
If ele.InnerText = "search " Then 'The space must be there
ele.InvokeMember("click")
End If
Next
但是我的下一个问题是,单击按钮后找不到该值。 我想我必须将角度值更新为?
HTML代码:
<input type="text" ng-model="hwbOrPiece" ng-trim="true" awb-or-piece="" md-no-asterisk="" name="hwbOrPiece" id="hwbOrPiece" maxlength="35" ng-keyup="$event.keyCode == 13 && query()" class="ng-valid md-input ng-valid-response-validator ng-valid-maxlength ng-not-empty ng-dirty ng-valid-awb-validator ng-valid-srk-validator ng-valid-piece-validator ng-valid-parse ng-touched" aria-invalid="false" style=""><div class="md-errors-spacer"></div>