【发布时间】:2014-12-09 11:04:42
【问题描述】:
我是 vb.net 的新手,我正在尝试使用 vb.net 自动用户登录到网站上的远程应用程序。我可以登录,但似乎无法弄清楚如何单击 div 来启动应用程序。相关代码:
ie = CreateObject("internetExplorer.Application")
ie.visible = True
ie.Navigate("https://thesite/default.aspx")
Do
If ie.ReadyState = 4 Then
Exit Do
End If
Loop
这一切都有效,但现在我需要点击 div:
<div tabindex="0" title="myApp" class="tswa_boss" onmouseover="tswa_bossOver(this)" onmouseout="tswa_bossOut(this)" onmouseup="goRDP(this, huge block of encrypted stuff");" onkeypress="onmouseup()">
由于我无法通过 id 抓取这个元素,所以我有以下代码来选择它。
For Each item As Object In ie.document.getelementsbytagname("div")
If item.getAttribute("title").Equals("myApp") Then
item.click()
End If
Next
代码执行得很好,但它没有通过 item.click() 触发 onmouseup() 事件。有谁知道我该如何触发这个?
【问题讨论】:
-
div没有附加点击处理程序。click()仅触发onclick,它不模拟onmouseup。 -
好吧,这就解释了为什么它不起作用。有什么方法可以触发 onmouseup?
-
为什么不附加一个点击处理程序呢?就像您附加
onkeypress一样。 -
很遗憾我无法更改页面的html...
-
item.onclick = item.onmouseup?
标签: html vb.net internet-explorer automation