none
How to close a popup internet Explorer window and return to the Parent window RRS feed

  • Question

  • I am testing a link inside a website. The link will pop up a window. Once this happen the script will not respond - It is not freezing but will not respond. It is kind of waiting for something!

    DealerPortalInternetSite = "Website"
    $ie = New-Object -ComObject InternetExplorer.Application 
    $ie.visible=$true
    $ie.Navigate($DealerPortalInternetSite)
    
    
    
    while($ie.busy -or $ie.ReadyState -ne 4) {
        start-sleep 1
    }
    
    $ie.document.IHTMLDocument3_getElementById("txtUserID").value = "Username"
    $ie.document.IHTMLDocument3_getElementById("txtPassword").value ="Passwor"
    
    while($ie.busy -or $ie.ReadyState -ne 4) {
        start-sleep 1
    }
    
    $ie.Document.IHTMLDocument3_getElementById("btnLogin").click()
    
    while($ie.busy -or $ie.ReadyState -ne 4) {
        start-sleep 1
    }
    
    if ($ie.LocationURL -eq "WebsiteLocation"){
        Write-Host "Log in to Dealer Portal is successful `n" -ForegroundColor Cyan
    } else {
        Write-Host "Log in to Dealer Portal has failed `n" -ForegroundColor Red
    }
    
    while($ie.busy -or $ie.ReadyState -ne 4) {
        start-sleep -Seconds 1
    }
    
        $fs2 = $ie.Document.IHTMLDocument3_getElementById("fs2")
        $menuFrame = $fs2.document.IHTMLDocument3_getElementById("oMenuFrame")
        $bos01 = $menuFrame.contentWindow.document.IHTMLDocument3_getElementById("bos01")
        $bosLink = $bos01.getElementsByTagName("a").item()
    
        $bosLink.click()
    The script is waiting for 

    $bosLink.click()

    the window will pop up but then you have to close it manually for the script to continue.


    how can I close the popup window and return to the parent window and make script continue.


    • Edited by Simsim1981 Monday, February 19, 2018 2:04 AM
    • Moved by Bill_Stewart Monday, April 30, 2018 9:12 PM This is not "scripts on demand"
    Monday, February 19, 2018 1:15 AM

All replies