从InternetExplorerMedium网站获取元素时,正在获取HRESULT:0x800A01B6异常



我正试图在VB.net上编写一些代码,打开一个网站并登录,然后运行一个报告。当我试图从网站上获取任何时,一切都很好,但OnClick属性中有此说明的属性="return oamSubmitForm('putParamView:paramForm','putParamview:paramForm:_idJsp106');"

基本上,如果你看到下面的代码,你会看到我点击了一些复选框,它运行得很好,但当我检索按钮时,它不会键入输入,当我在调试时使用whatc时,它实际上有网站的链接。

这是我的代码(我跳过了登录部分):

Private Sub open Page()
ieb = New SHDocVw.InternetExplorerMedium()
ieb.Navigate("http://example.example/qptheme2/pages/index.faces")
ieb.visible = True
ieb.Silent = True
While Not (ieb.ReadyState = WebBrowserReadyState.Complete)
    Application.DoEvents()
End While
If v.checked = False Then
    v.Click()
End If
v = ie.Document.GetElementById("inputParamView:paramForm:inputParametertuesday")
If v.checked = False Then
    v.Click()
End If
v = ie.Document.GetElementById("inputParamView:paramForm:_idJsp106")
v.Click() '<-- IT FAILS HERE Exception HRESULT: 0x800A01B6

如果我查看手表,它会显示mshtml。HTML锚元素类{http://example.example/qpreport/savedpages/savedReports.faces#}如果我从页面中检查源代码,这就是我试图获得的元素:

<a id="inputParamView:paramForm:_idJsp106" onclick="return
oamSubmitForm('inputParamView:paramForm','inputParamView:paramForm:_idJsp106');" href="#"

我不知道它是否与属性OnClick有关。

如果你能帮助我解决这个问题,我将不胜感激。

我自己找到了解决方案。我只需要将正在检索的元素实例化为mshtml。HTML锚元素类之后,我可以点击它。

Dim l As mshtml.HTMLAnchorElementClass = ieb.Document.GetElementById("inputParamView:paramForm:_idJsp106")
l.click()

相关内容

最新更新