html – 使用powershell单击网页上的链接,然后传递凭据

html – 使用powershell单击网页上的链接,然后传递凭据,第1张

概述我正在尝试测试我们构建的具有临时ssl证书的网页,问题是当我转到页面时,我得到IE安全警告,证明ssl证书无效,有两个链接用于关闭页面,以及另一个进入页面.我能够使用power shell打开IE并单击ssl警告页面上的链接,但现在我需要填充用户名和密码输入框,然后单击登录按钮. $url = "res://ieframe.dll/invalidcert.htm?SSLError=50331648 我正在尝试测试我们构建的具有临时ssl证书的网页,问题是当我转到页面时,我得到IE安全警告,证明ssl证书无效,有两个链接用于关闭页面,以及另一个进入页面.我能够使用power shell打开IE并单击ssl警告页面上的链接,但现在我需要填充用户名和密码输入框,然后单击登录按钮.

$url = "res://IEframe.dll/invalIDcert.htm?SSLError=50331648#https://10.2.2.1:8050/showme.do"$IE = New-Object -comobject InternetExplorer.Application $IE.visible = $true $IE.silent = $true $IE.Navigate( $url )while( $IE.busy){Start-Sleep 1} $seclink = $IE.document.getElementsByTagname('A') | Where-Object {$_.innerText -   eq 'Continue to this website (not recommended).'} $seclink.click() $IE.document.getElementsByType("input") | where { $.name -eq "j_username" }.value = "user"$IE.document.getElementsByname("input") | where { $.name -eq "j_password" }.value = "password"$loginBtn = $IE.document.getElementsByID('input') | Where-Object {$_.Type -eq 'button' -and $_.Value -eq 'Loginbutton'} $loginBtn.click()

所以现在页面打开但输入字段没有填充或单击按钮,我需要某种循环或while语句吗?

谢谢

解决方法 您点击链接后需要等到页面完成加载.

$url = "res://IEframe.dll/invalIDcert.htm?SSLError=50331648#https://10.2.2.1:8050/showme.do"$IE = New-Object -comobject InternetExplorer.Application $IE.visible = $true $IE.silent = $true $IE.Navigate( $url )while( $IE.busy){Start-Sleep 1} $seclink = $IE.document.getElementsByTagname('A') | Where-Object {$_.innerText -   eq 'Continue to this website (not recommended).'} $seclink.click() while( $IE.busy){Start-Sleep 1}$IE.document.getElementsByType("input") | where { $.name -eq "j_username" }.value = "user"$IE.document.getElementsByname("input") | where { $.name -eq "j_password" }.value = "password"$loginBtn = $IE.document.getElementsByID('input') | Where-Object {$_.Type -eq 'button' -and $_.Value -eq 'Loginbutton'} $loginBtn.click()
总结

以上是内存溢出为你收集整理的html – 使用powershell单击网页上的链接,然后传递凭据全部内容,希望文章能够帮你解决html – 使用powershell单击网页上的链接,然后传递凭据所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1073551.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存