querySelectorAll of IE COM 在 IE 8 中不起作用



我正在通过Powershell访问InternetExplorer.Application COM。我正在尝试使用documentquerySelector,但它没有返回任何结果。我目前正在使用IE8。

$ie = New-Object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.Navigate("www.google.com")

if ($ie.Busy) { Start-Sleep 1 }
# This statement works
@($ie.Document.getElementsByTagName("a"))[0]
# This statement doesn't work, though querySelectorAll 
# exist in the document object
@($ie.Document.querySelectorAll("a"))[0]
# I tried this
$ie.Document.querySelectorAll("a") -eq $null # evaluates to True

使用 IDocumentSelector 前缀来引用该方法,如下所示:

$ie.Document.IDocumentSelector_querySelectorAll("a")

有一个或两个Powershell浏览器API故障排除资源可能会有所帮助。如果文档类型导致浏览器呈现几乎是标准或怪癖模式,则嘶嘶声可能会有所帮助,这些模式不支持querySelectorAll。

最新更新