对象 htmldivelement 不点击 IE11
Object htmldivelement doesn't click on IE11
将转到学校页面并单击“赞”按钮。我要去的页面对象 htmldivelement
功能没有点击按钮。我的命令是 运行 IE10,但它不适用于 IE11。
Set hIE = CreateObject("InternetExplorer.Application")
hURL = "http://mukerremalikayanilkokulu.meb.k12.tr/icerikler/eglen-dusun-bul_6506730.html"
With hIE
.Navigate hURL
.Visible = True
Do While hIE.Busy
Loop
End With
Set haberss = hIE.document.getElementsByClassName("begen")
For Each haberbb In haberss
If haberbb = "begen" Then
Do While hIE.Busy
Loop
haberbb.Click
Set hIE = hIE.Quit
Exit For
Else
Do While hIE.Busy
Loop
haberbb.Click
Set hIE = hIE.Quit
Exit For
End If
haberbb
按钮在 IE10 上有效,但在 IE11 上无效。
我不知道这是否有效或需要某种形式的登录。无法手动点赞
这里有3种编码方式:
Ie.document.querySelector(".begen").click
Ie.document.querySelector(".begen").FireEvent "OnClick"
Ie.document.parentWindow.execScript "document.querySelector('.begen').click;"
Option Explicit
Public Sub AttemptClick()
Dim ie As New InternetExplorer
With ie
.Visible = True
.Navigate2 "http://mukerremalikayanilkokulu.meb.k12.tr/icerikler/eglen-dusun-bul_6506730.html"
While .Busy Or .readyState < 4: DoEvents: Wend
.document.querySelector(".begen").FireEvent "onclick"
.document.querySelector(".begen").Click
.document.parentWindow.execScript "document.querySelector('.begen').click();"
Stop
.Quit
End With
End Sub
除了 QHarr 的回答之外,您的 Do While...Loop
也不完全正确。
- 你应该在循环中做一些事情,否则你只会增加 CPU 的使用。您至少应该在两者之间添加一个
DoEvents
以允许 windows 处理其他 programs/messages.
- 您似乎没有在等待页面加载完成。尝试将
Or ReadyState < READYSTATE_COMPLETE
添加到循环条件。
将其放在一起,循环应该如下所示:
Do While IE.Busy Or IE.ReadyState < READYSTATE_COMPLETE ' = 4
DoEvents
Loop
以下是一些可能有帮助的其他参考资料:
Failproof Wait for IE to load
How to wait for the page to load after click
将转到学校页面并单击“赞”按钮。我要去的页面对象 htmldivelement
功能没有点击按钮。我的命令是 运行 IE10,但它不适用于 IE11。
Set hIE = CreateObject("InternetExplorer.Application")
hURL = "http://mukerremalikayanilkokulu.meb.k12.tr/icerikler/eglen-dusun-bul_6506730.html"
With hIE
.Navigate hURL
.Visible = True
Do While hIE.Busy
Loop
End With
Set haberss = hIE.document.getElementsByClassName("begen")
For Each haberbb In haberss
If haberbb = "begen" Then
Do While hIE.Busy
Loop
haberbb.Click
Set hIE = hIE.Quit
Exit For
Else
Do While hIE.Busy
Loop
haberbb.Click
Set hIE = hIE.Quit
Exit For
End If
haberbb
按钮在 IE10 上有效,但在 IE11 上无效。
我不知道这是否有效或需要某种形式的登录。无法手动点赞
这里有3种编码方式:
Ie.document.querySelector(".begen").click
Ie.document.querySelector(".begen").FireEvent "OnClick"
Ie.document.parentWindow.execScript "document.querySelector('.begen').click;"
Option Explicit
Public Sub AttemptClick()
Dim ie As New InternetExplorer
With ie
.Visible = True
.Navigate2 "http://mukerremalikayanilkokulu.meb.k12.tr/icerikler/eglen-dusun-bul_6506730.html"
While .Busy Or .readyState < 4: DoEvents: Wend
.document.querySelector(".begen").FireEvent "onclick"
.document.querySelector(".begen").Click
.document.parentWindow.execScript "document.querySelector('.begen').click();"
Stop
.Quit
End With
End Sub
除了 QHarr 的回答之外,您的 Do While...Loop
也不完全正确。
- 你应该在循环中做一些事情,否则你只会增加 CPU 的使用。您至少应该在两者之间添加一个
DoEvents
以允许 windows 处理其他 programs/messages. - 您似乎没有在等待页面加载完成。尝试将
Or ReadyState < READYSTATE_COMPLETE
添加到循环条件。
将其放在一起,循环应该如下所示:
Do While IE.Busy Or IE.ReadyState < READYSTATE_COMPLETE ' = 4
DoEvents
Loop
以下是一些可能有帮助的其他参考资料:
Failproof Wait for IE to load
How to wait for the page to load after click