我设法使其与SendKeys一起使用。但是,使用SendKeys浏览网页不是最佳解决方案。我一直试图使此代码无法成功运行。它会打开网页,什么也没发生。
链接类:class="a_1_610"
链接文本:Dashboard
从源代码:
<tr>
<td class="nowrap"><span class="h_1_610" style="display: none;">Dashboard</span>
<a href="DA3192.html" class="a_1_610" >
Dashboard</a>
</td>
</tr>
DA3192.html
一直在变化。下次您导航到网页时,它是DA3672.html
之类的。
问题在于所有链接都具有class="a_1_610"
。因此,我试图通过链接文本来捕获它,但是它似乎不起作用(什么也没有发生)。该网站不可用于公共用途,只能用于私人用途,因此无法共享。除了SendKeys之外,还有其他方法可以使它工作吗?
Sub GoToWebsiteTest()
Dim appIE As InternetExplorerMedium
'Set appIE = Nothing
Dim objElement As Object
Dim objCollection As Object
Set appIE = New InternetExplorerMedium
sURL = "http://mysite/"
With appIE
.Navigate sURL
.Visible = True
End With
Do While appIE.Busy Or appIE.ReadyState <> 4
DoEvents
Loop
Set objCollection = appIE.Document.getElementsByTagName("a")
For Each hyper_link In objCollection
If hyper_link.innerText = "Dashboard" Then
hyper_link.Click
Exit For
End If
Next
Set appIE = Nothing
End Sub
答案 0 :(得分:1)
您可以尝试查看innertext是否带有“ bug”并具有空白的字符,请使用LIKE和通配符。
-XX:MaxHeapSize=30g
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=512m
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:InitiatingHeapOccupancyPercent=70
-XX:-OmitStackTraceInFastThrow
-XX:+AlwaysPreTouch
-XX:+UseStringDeduplication
-XX:+UseCompressedOops
-Xloggc:/usr/local/company/logs/gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=10
-XX:GCLogFileSize=100M
-XX:+PrintAdaptiveSizePolicy
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCCause
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintHeapAtGC
-XX:+PrintReferenceGC
-XX:+PrintTenuringDistribution
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/usr/local/company/logs/heapdump_126960.hprof
告诉我它是否有效!