目前,我有一个成功的基于Excel的网络刮板程序,它通过我公司的项目跟踪系统并获取我需要的信息(项目经理,发布日期等)我的问题是我正在尝试添加一项新功能,检查每个打开的故障单面板上的辅助选项卡,导致程序看不到href /按钮(仅在第一张故障单后)并崩溃。
此外:
The secondary tab I am accessing on each ticket: "Impact Analysis"
单击“影响分析”选项卡(计数器是我的迭代器,因为Ids在故障单之间更改):
identification3 = "dijit_layout_TabContainer_1_tablist_dijit_layout_ContentPane_" & CStr(5 + (counter * 18))
Set impactObj = doc.getElementById(identification3)
impactObj.Click
此行显示错误:
impactObj.Click
注意:网站仅限内部Intranet
由于
编辑:在可能导致此问题的页面之间切换时是否存在任何常见问题或错误?
编辑:添加代码:
Sub CQscrub()
Dim i As Long
Dim objElement As Object
Dim objCollection As Object
Dim objCollection2 As Object
Dim ie As InternetExplorer
Dim numbers() As String
Dim size As Integer
Dim row As Integer
Dim objLead As Object
Dim lead As String
Dim state As String
Dim releasedate As String
Dim inv As String
Dim counter As Integer
Dim identification As String
Dim identification2 As String
Dim identification3 As String
Dim identification4 As String
Dim closeObj As Object
Dim existingTab As Boolean
Dim searchStringObj As Object
' Creating dynamic array
size = WorksheetFunction.CountA(Worksheets(1).Columns(1)) - 4
ReDim numbers(size)
For row = 0 To size
numbers(row) = Cells(row + 10, 1).Value
Next row ' Check : Cells(row, 2) = numbers(row - 10)
' Creating IE instance
Set ie = CreateObject("InternetExplorer.Application")
ie.Height = 1000
ie.Width = 1000
ie.Visible = True
ie.navigate "http://clearquest/cqweb/"
Application.StatusBar = "Loading http://clearquest/cqweb"
Do While ie.Busy Or Not ie.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:03"))
Application.StatusBar = "Please wait..."
' Second declaration zone
Dim doc As HTMLDocument, yourObj As Object, stateObj As Object, dateObj As Object, invObj As Object, impactObj As Object, tabObj As Object
Set doc = ie.document
' First searching for "search" bar and inputting WR
Set objCollection = ie.document.getElementsByTagName("input")
i = 0
While i < objCollection.Length
If objCollection(i).Name = "cqFindRecordString" Then
Set searchStringObj = objCollection(i)
'objCollection(i).Value = numbers(counter)
End If
i = i + 1
Wend
Set objElement = ie.document.getElementById("cqFindRecordButton")
' Starting main loop
For counter = 0 To size - 1
' Clicking search button
searchStringObj.Value = numbers(counter)
objElement.Click
Do While ie.Busy Or Not ie.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:05"))
' Section scraping the webpage
' Finding the IT Lead
identification = "cq_widget_CqFilteringSelect_" & CStr(9 + (counter * 46))
Range("D" & (10 + counter)).Value = identification ' Test prompt
Set yourObj = doc.getElementById(identification)
lead = yourObj.Value
Range("B" & (10 + counter)).Value = lead
' Finding WR State
identification2 = "cq_widget_CqTextBox_" & CStr(2 + (counter * 3))
Range("E" & (10 + counter)).Value = identification2 ' Test prompt
Set stateObj = doc.getElementById(identification2)
state = stateObj.Value
Range("C" & (10 + counter)).Value = state
' Clicking Impact Analysis Tab
' Application.Wait (Now + TimeValue("0:00:05"))
'''''''''''''''''''''''''' Problem Area '''''''''''''''''''''''''''''''''''''''''''
identification3 = "dijit_layout_TabContainer_1_tablist_dijit_layout_ContentPane_" & CStr(5 + (counter * 18))
Range("F" & (10 + counter)).Value = identification3 ' Test prompt
Set impactObj = doc.getElementById(identification3)
impactObj.Click
Do While ie.Busy Or Not ie.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:01"))
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Finding UAT Involvement
' Set yourObj = doc.getElementsByClassName("dijitReset dijitInputField dijitInputContainer")(0).getElementsByTagName("input")(1)
' cqTable dojoDndContainer
'identification = "cq_widget_CqTable_" & CStr(7 + (counter * 9))
'Set invObj = doc.getElementsByClassName("cqListBox cqReadonlyControl cqListControl cqListBoxReadOnly dijitReadOnly")(7)
'inv = invObj.innerText
'Range("E" & (10 + counter)).Value = inv
' Closing tab
Set closeObj = doc.getElementsByClassName("dijitInline dijitTabCloseButton dijitTabCloseIcon")(0)
closeObj.Click
Do While ie.Busy Or Not ie.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Next counter
' Closing final open tab
Do While ie.Busy Or Not ie.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Set closeObj = doc.getElementsByClassName("dijitInline dijitTabCloseButton dijitTabCloseIcon")(0)
closeObj.Click
Do While ie.Busy Or Not ie.readyState = READYSTATE_COMPLETE
DoEvents
Loop
' Click logout, enter password in login, click login?
' Closing down program
Set objElement = Nothing
Set objCollection = Nothing
Application.StatusBar = ""
MsgBox "Done!"
End Sub