gpt4 book ai didi

javascript - VBA点击悬停下拉菜单

转载 作者:行者123 更新时间:2023-11-28 00:48:52 25 4
gpt4 key购买 nike

我收到了类似于 this question here 的请求,我刚刚发现并正在调查 this request here as well 。我正在尝试构建一个 VBA 宏来抓取一些网络数据,并且我已经完成了登录屏幕,但现在我陷入了困境,因为该页面似乎是用 javascript 编写的,而且我完全不熟悉如何使用它。我对 HTML 非常模糊,并且一直在自学。下面是到目前为止我的 VBA,其中取消的代码行显示了我尝试过但不起作用的代码。我想做的是单击“报告”链接,该链接位于由鼠标悬停激活的名为“我的 Sequentra”的下拉菜单下。感谢您的帮助。

Sub SingleSiteReportPull()

Dim ie As Object
Dim form As Variant, button As Variant

Set ie = CreateObject("InternetExplorer.Application")

'''''Set input boxes for username, password, & site to pull report for'''''
myusername = InputBox("Enter Your Sequentra Username")
mypassword = InputBox("Enter Your Sequentra Password")
searchsite = InputBox("Which site would you like to pull a report for?")

'''''Go to webpage'''''
With ie
.Visible = True
.navigate ("https://www.sequentra.net/seq-security/ssoLogin.go")

While ie.ReadyState <> 4
DoEvents
Wend

'''''enter username & password'''''
On Error Resume Next

ie.document.getelementsbyname("j_username").Item.innertext = myusername
ie.document.getelementsbyname("j_password").Item.innertext = mypassword

'''''submit login info'''''
With appIE
ie.document.forms(0).submit
End With

'''''click through menus to reports'''''
'Set frms = ie.document.getelementsbyTagname("FORM")
'Set button = form(0).onsubmit
'form(0).submit

'Set link = ie.document.getelementsbytagname("a")
'For Each l In link
' If link.classname = "appReportsShow.do" Then
' link.Click
' Exit For
'End If
'Next l

'ie.documents.parentWindow.execScript "loadFrame('appReportsShow.do')", "JavaScript"

'Do While ie.busy: DoEvents: Loop

End With
Set ie = Nothing
End Sub

这是我正在查看的页面源代码:

<li class="clsTopMenuItem active" onmouseover="expandTopMenu(this)" onmouseleave="collapseTopMenu(this)"><a href="javascript:void(0);">My Sequentra</a>                 
<ul style="display: none;">
<li class="clsSubMenu" onmouseover="expandMenu(this)" onmouseleave="collapseMenu(this)"><a onclick="loadFrame('javascript:goHome()', this, {isNewWindow: false, width:-1, height:-1})" href="javascript:void(0);">Home</a>
</li>
<li class="clsSubMenu" onmouseover="expandMenu(this)" onmouseleave="collapseMenu(this)"><a onclick="loadFrame('appReportsShow.do', this, {isNewWindow: false, width:-1, height:-1})" href="javascript:void(0);">Reports</a>
</li>
<li class="clsSubMenu" onmouseover="expandMenu(this)" onmouseleave="collapseMenu(this)"><a onclick="loadFrame('notificationMyAlertListShow.go', this, {isNewWindow: false, width:-1, height:-1})" href="javascript:void(0);">My Alerts</a>
</li>
</ul>
</li>

最佳答案

找到了similar issue on ozgrid ,将其用作基点并使其单击。解决方案如下。

ie.document.all.Item
Call ie.document.parentWindow.execScript("loadFrame('appReportsShow.do')", "JavaScript")
.Click

关于javascript - VBA点击悬停下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27028052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com