Execute powershell commands after displaying a javascript confirm prompt in a webpage [IE]

76 Views Asked by At

I'm using powershell to navigate in a website and test if is it available or not.

I found a problem with a search button that I need to click it. So when I click it, I get a confirm prompt with a "Yes" or "No" responses.

I searched how can I automate clicking on the "Yes" response and I found that the WASP module can did this job.

And when I tested it, I found an unexpected problem in the begining before while clicking on the search button. The script is stucking on the click command:

$searchbutton.click()

Of course, it will stuck there because the confirm prompt need a response.

So how can I detach the click command from the current process ? or how can I execute another commands while stucking in the click command ?

Here is a part of the main code:

Add-PSSnapin WASP
$url=...
$ie = new-object -ComObject "InternetExplorer.Application"
$ie.visible = $true
$ie.silent = $false
$ie.navigate($url)
while($ie.Busy) { Start-Sleep -Milliseconds 100 }
$doc = $ie.Document
$searchbutton=$doc.getElementById("searchbutton")
$searchbutton.click()
echo "click done" #this line will never be executed
$IEProcess = Select-Window -Title "my title"
$IEProcess | Send-Keys "{Enter}"

Thank you for your responses

Best regards

0

There are 0 best solutions below