Powershell 和 Internet Explorer 标签

安德烈亚斯

试图让 powershell ISE 自动转到网站并单击“否”按钮。我试图通过标签名称获取元素,但它只是启动 Internet Explorer,但之后它无法获取元素,任何帮助将不胜感激:

$web = "https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flnks.gd%2Fl%2FeyJhbGciOiJIUzI1NiJ9.eyJidWxsZXRpbl9saW5rX2lkIjoxMDEsInVyaSI6ImJwMjpjbGljayIsImJ1bGxldGluX2lkIjoiMjAyMTA1MTEuNDAyNjU1NjEiLCJ1cmwiOiJodHRwczovL3d3dy5mYWEuZ292L2Nvcm9uYXZpcnVzL3dlbGxuZXNzX2NoZWNrLyJ9.e4fctVtbkCtZ1yDQ2f2ZIyUCLgx3KceG4A0AIuiZTPk%2Fs%2F770634691%2Fbr%2F106182191351-l&data=04%7C01%7Csasha.tabib%40lstechllc.com%7Cb2bcd86b5a174ff6488108d914916338%7C93bb738069e94c7ca5fbfd30a5f59cc9%7C0%7C0%7C637563436952056800%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0KULfdRzubnmWAdCqW94wE4%2F7fFTyuXSwNsCBSTGfkY%3D&reserved=0"
$ie = New-Object -Com InternetExplorer.Application
$ie.Visible = $true
$ie.Navigate($web)
$ie = getelementsbytagname('div')

错误显示为在此处输入图像描述

跟随

您需要在该Navigate()方法后等待一段时间才能让 IE 有时间完成。
另外,该getElementsByTagName()方法不是一个独立的函数,而是$ie.

尝试

$ie = New-Object -ComObject InternetExplorer.Application
$ie.Visible = $true    

$ie.Navigate("https://www.faa.gov/coronavirus/wellness_check/")
# wait for it..
while ($ie.Busy -and $ie.ReadyState -ne 4) { Start-Sleep -Seconds 1 }

# find the 'NO' button and click it
($ie.Document.getElementsByTagName('button') | Where-Object { $_.id -eq 'noInit' }).Click()
# wait for it..
while ($ie.Busy -and $ie.ReadyState -ne 4) { Start-Sleep -Seconds 1 }

# and so on..

# when all done, release the COM object from memory
$ie.Quit()
$null = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($ie)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

PS 你的原始网址让我重定向到"https://www.faa.gov/coronavirus/wellness_check/",所以我在上面的代码中使用了它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Powershell 启用 Internet Explorer 下载

Transpiller和Internet Explorer 8

无法使用 PowerShell 隐藏 Internet Explorer 窗口

Excel VBA错误462和Internet Explorer

Internet Explorer上的AJAX和setTimeout

CSS目标Internet Explorer和屏幕宽度

Bootstrap 和 Internet Explorer 11 问题

Internet Explorer和Jquery Ajax错误

Chrome与Firefox和Internet Explorer的空间不同

Internet Explorer和Firefox上缺少CSS

Internet Explorer和Java安全性

错误的 img 标签在 Internet Explorer 中不显示图像

Internet Explorer中'script'标签的'onload'处理程序

通过C ++将脚本标签添加到Internet Explorer

如何在Internet Explorer的预标签中包装文字?

在同一台计算机上运行Internet Explorer 6,Internet Explorer 7和Internet Explorer 8

通过Powershell在“ Intranet模式”下打开Internet Explorer网站

Powershell如何在Internet Explorer中允许被阻止的内容

使用Powershell浏览网站而无需使用Internet Explorer

使用Powershell更改受信任域的Internet Explorer安全设置

从PowerShell启动时如何正确关闭Internet Explorer?

Internet Explorer(64位)和Internet Explorer之间有什么区别?

如何禁用Internet Explorer和Firefox中的缩放?

Firefox和Internet Explorer上的CSS中子元素的定位问题

此处映射javascript api 3.1和Internet Explorer支持

Internet Explorer CSS hack负数和较少的编译

Internet Explorer和Safari Mobile CSS过滤器反转

内容在Firefox和Internet Explorer中不起作用?

Firefox和Internet Explorer显示垃圾而不是特定站点