我有一个Internet Explorer登录脚本,可以正常工作。但我想走得更远,因为在首次登录后,Internet Explorer会打开一个新选项卡,并带有另一个“登录”表单。因此$ IE.visible = $ False不适用于自动打开的第二个选项卡,而且我也不知道如何将焦点放在第二个选项卡上以输入其他凭据并将其置于不可见状态。
$variablePass = $variablePass.Text
$username = "testUser"
$username2 = "testUser2"
$password = "testPass" + $variablePass
$password2 = "testPass2"
$ie = New-Object -com InternetExplorer.Application
$ie.visible = $false
$ie.Height = 720
$ie.Width = 1280
$ie.navigate("https://mylink.com")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
#This one work fine
$ie.document.getElementById("username").value = "$username"
$ie.document.getElementById("password").value = "$password"
$ie.document.getElementById("btnSubmit").click()
# Here comes the problem, after IE reach mylink.com and do the login script, the a new tab pop up with another login form
$ie.document.getElementById("username").value = "$username2"
$ie.document.getElementById("password").value = "$password2"
$ie.document.getElementById("loginBtn").click()
因此,我该如何执行第二个“登录”表单。最好在不可见模式下,我的意思是$ IE.visible = $ False
答案 0 :(得分:0)
您是否可以更改IE的配置以防止这种情况发生?
https://helpdeskgeek.com/how-to/force-ie-to-open-link-in-new-tab/
您可以手动配置IE,或使用PowerShell编辑注册表以强制执行该特定配置...