我正在工作的自动化要求我打开网页,单击选项卡并在文本区域粘贴一些数据,然后单击保存按钮。我正在使用vb .net Visual Studio 2017,这是我的HTML
<li><a href="#tab-overview"><span>Overview</span></a></li>
<li id="tab-vendor-link" style="display:none">
<a href="#tab-vendor"><span>Vendor Info</span></a>
</li>
<li>
<a href="#tab-correspondence" id="tab_correspondence">
<span>Correspondence
<img id="update_correspondence_link" src="/images/small_refresh.png?
v=420740.386111111&killcache=201108172214" border="0"
class="expandable"/>
<img src="/images/small_load.gif?
v=420740.386111111&killcache=201108172214"
id="update_correspondence_indicator"
style="display:none;" align="top" /></span></a>
</li>
<li><a href="#tab-work_log" id="tab_work_log"><span>Work Log
<img id="update_work_log_link" src="/images/small_refresh.png?
v=420740.386111111&killcache=201108172214" border="0"
class="expandable"/>
<img src="/images/small_load.gif?
v=420740.386111111&killcache=201108172214"
id="update_work_log_indicator"
style="display:none;" align="top" />
</span></a>
</li>
我要查找的标签是标签对应,我可以看到我的webbrowser正在导航到该页面并单击标签并粘贴数据并单击 保存,但是一旦我加载页面,我看不到数据。不知怎的,它没有被捕获
For Each element As HtmlElement In Me.WebBrowser1.Document.All
If InStr(element.Id, "tab_correspondence") Then
element.InvokeMember("Click")
End If
Next
For Each element As HtmlElement In Me.WebBrowser1.Document.All
If InStr(element.Name, "correspondence") Then
element.InnerText = "THis is a sample text"
End If
Next
For Each element As HtmlElement In Me.WebBrowser1.Document.All
If InStr(element.Id, "left_nav") Then
element.InvokeMember("Click")
End If
Next
Do Until Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete
Application.DoEvents()
Loop
For Each element As HtmlElement In Me.WebBrowser1.Document.All
If InStr(element.Id, "save-button") Then
element.InvokeMember("Click")
End If
Next
ID似乎没有问题,因为我可以看到标签被点击并且数据被粘贴和保存,但问题似乎与web浏览器有关。