我正在尝试编写一个脚本进入网站上的链接,导航到设置,更改设置,然后返回主页点击下一个链接并重复直到所有链接都是点击。
一切都适用于第一个循环,但当它返回主页面点击下一个链接时,我得到一个“访问被拒绝”错误。
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := true
wb.Navigate(path)
IELoad(wb)
Elements := {}
count := 0
Elements := wb.document.getElementsByTagName("a")
Loop % Elements.length {
ComObjError(false)
While (value == "") {
value := Elements.25.innerText
Sleep 100
}
ComObjError(true)
Elements[25].click()
IELoad(wb)
sleep, 2000
wb.document.getElementsByTagName("a")[28].click()
IELoad(wb)
sleep, 2000
wb.document.All.project_custom_field_values_142.value := "North West"
ClickElementWithThisText("Projects", wb.document, "a")
if A_Index > Elements.length
break
}
IELoad(wb)
{
If !wb
Return False
Loop
Sleep,100
Until (wb.busy)
Loop
Sleep,100
Until (!wb.busy)
Loop
Sleep,100
Until (wb.Document.Readystate = "Complete")
Return True
}
ClickElementWithThisText(text, document, tagName)
{
elements := document.getElementsByTagName(tagName)
Loop % elements.length
if (elements[A_Index - 1].innerText = text)
{
elements[A_Index - 1].click()
break
}
}