我有一个打开网页的vbscript,然后点击一个按钮。该按钮在新窗口上打开一个新的弹出网页(注意:窗口不是标签页)。
我希望在我的脚本按下按钮并打开一个新窗口后,检测并单击该新窗口中名为id="pagesHeaderLikeButton"
的按钮,然后关闭该窗口。
到目前为止我的脚本:
Set IE = createobject("internetexplorer.application")
strURL = "website"
Do While True
IE.navigate strURL
IE.Visible = true
Do While (IE.Busy Or IE.READYSTATE <> 4)
WScript.Sleep 1000
Loop
Set Popupbutton = IE.Document.GetElementsByClassName("single_like_button btn3-wrap")
for each button in Popupbutton
button.click
WScript.Sleep 5000
exit for
objWindow.Quit
WScript.Sleep 5000
next
Loop
另外要注意。我想这样做,因为弹出窗口总是会有一个新的网址。
答案 0 :(得分:0)
For Each wnd In CreateObject("Shell.Application").Windows
If InStr(wnd.Name,"Internet") Then
if InStr(wnd.Document.URL,"facebook.com") Then
Set IE2 = wnd
Exit For
End If
End If
Next
以上脚本将找到任何已打开的IE,其URL为:facebook.com/***,并将IE2设置为已打开的IE。
所以按下按钮:
Set Butlike = IE2.Document.getElementsById("pagesHeaderLikeButton")
For Each btn In Butlike
button.click
Next