Excel 单击复选框仅适用于第一个实例VBA Selenium(元素单击拦截)
两个小时以来,我一直在试图解决在JavaScript加载的网页上选中复选框的问题。 这是所需页面的html页面 这是我到现在为止的密码Excel 单击复选框仅适用于第一个实例VBA Selenium(元素单击拦截),excel,vba,selenium,Excel,Vba,Selenium,两个小时以来,我一直在试图解决在JavaScript加载的网页上选中复选框的问题。 这是所需页面的html页面 这是我到现在为止的密码 Private driver As New Selenium.ChromeDriver Const sURL As String = "https://eservices.moj.gov.kw/" Sub Test() With driver .Start "Chrome", sURL
Private driver As New Selenium.ChromeDriver
Const sURL As String = "https://eservices.moj.gov.kw/"
Sub Test()
With driver
.Start "Chrome", sURL
.Get sURL
'#https://eservices.moj.gov.kw/#
'//*[@id="loginDiv"]/div/a[1]
.Wait 2000
''.FindElementByXPath("//*[@id='loginDiv']/div/a[1]").Click
.FindElementByClass("headerTabLeft").Click
.Wait 3000
.FindElementById("txtUserID").SendKeys "username"
.FindElementById("txtPWD").SendKeys "password"
.FindElementById("txtCaptcha").Click
.Wait 5000
.FindElementByXPath("//*[@id='frmLogin']/input[3]").Click
.Get sURL & "lawyerViews/lawOrders/"
.FindElementByLinkText("أوامر أداء جاهزة للدفع").Click
Dim dRows As Object
Set dRows = .FindElementsByCss("table.table-striped tbody tr")
'Debug.Print dRows.Count
.FindElementById("checkAll").Click
.Wait 3000
.FindElementById("checkAll").Click
.Wait 3000
Dim r As Long
For r = 1 To dRows.Count
Dim sRequestID As String
sRequestID = dRows.Item(r).FindElementsByTag("td")(2).Text
Dim x
x = Application.Match(Val(sRequestID), ActiveSheet.Columns(1), 0)
If Not IsError(x) Then
backP:
.Wait 2000
On Error Resume Next
On Error GoTo backP
.FindElementByXPath("//*[@id=""toBePaid[" & r - 1 & "]""]").Click
.Wait 2000
'.FindElementByXPath("//input[@type='checkbox'][@value='200512308']").Click
'.FindElementById("toBePaid[" & r - 1 & "]").WaitSelection True, 20000
'.Wait 2000
'.FindElementByCss("[type=checkbox][value='" & sRequestID & "']").Click
'.FindElementById("toBePaid[" & r - 1 & "]").Click
On Error GoTo 0
Debug.Print sRequestID & " Checked"
End If
Next r
Stop
End With
End Sub
第一个复选框被选中后,我收到一条错误消息,上面写着“Element click intercepted”
我尝试使用id、xpath、css,但没有办法
有什么想法吗?虽然对于自动化来说并不理想,但似乎有一个解决办法,即通过聊天中的ths进行操作,即通过javascript执行单击,并确保使用属性而不是id css选择器
.ExecuteScript "document.querySelector(""[id='toBePaid[" & r - 1 & "]']"").click();"
那么,请问这条消息发生在哪一行?在那一点上,url的价值是什么?非常感谢我的导师。tries位于行
之后,如果不是IsError(x),则。我试图在匹配activesheet中A列中的复选框后检查复选框。如果在工作表上找到编号,则选中与该编号相关的复选框。例如200512308
。。每个复选框都没有特定的url。我认为这是javascript。这个页面。FindElementByLinkText(“代码”)。点击。这是元素检查
返回的值是一个表Set dRows=.findelementsbycs(“table.table-striped tbody tr”)
,在该表中,每行都有自己的复选框,如
。0表示第一行,1表示第二行,2表示第三行,依此类推。您是否可以在不包含元素的情况下匹配元素。单击?有或没有F8等待?