internet-explorer - IE COM 的 querySelectorAll 在 IE 8 中不起作用

标签 internet-explorer powershell com internet-explorer-8 powershell-2.0

我正在通过 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")

onetwo powershell 浏览器 API 故障排除资源可能会有所帮助。 Sizzle如果 doctype 可能会有所帮助导致浏览器渲染的几乎是标准或怪异模式,它们不支持 querySelectorAll。

关于internet-explorer - IE COM 的 querySelectorAll 在 IE 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10683351/

相关文章:

azure - 将 Intune 范围标记分配给 Azure Azure AD 组

regex - 在 powershell 选择字符串输出中删除以 *(asterisk) 开头的行

azure - 无法使用 Azure DevOps Pipeline 更新 RBAC 角色

c# - C++ COM C# 混合模式互操作

c++ - 在 vs2005 中通过 COM 引用 .net 4 库

css - 当悬停子 <select> 的选项时,元素丢失 "hover"状态

html - 将鼠标悬停在图像上时,奇怪的故障会导致内容移动

html - Internet Explorer 7 错误

c# - IE9 缓存文本文件

c# - 完全重启后如何卸载未使用的 COM 对象/库?