Working on a quick Powershell script to use the IE object to enter values and submit a web page with a modal dialog. I want to be able to invoke the modal dialog, check some boxes on the dialog, and then close it and return to the page. I can invoke the modal dialog but nothing executes after the line to invoke the dialog until it is closed.
Powershell
$ie = new-object -com "InternetExplorer.Application"
$ie.visible = $true
$ie.navigate($url); do {sleep 1} until (-not ($ie.Busy))
$doc = $ie.Document
$books = $doc.getElementById(“searchBooks”).click();
Javascript
var ret = window.showModalDialog('selectBooks.aspx, books, ...);
I need a way to invoke commands in the context of the dialog. Tried running in the background and creating a runspace but no joy with either solution
& {$books = $doc.getElementById(“searchBooks”).click();}
(blocking)
$rs = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs.Open()
$rs.SessionStateProxy.SetVariable("doc", $doc)
$p = $rs.CreatePipeline( { $books = $doc.getElementById(“searchBooks”).click(); } )
$p.Input.Close()
$p.InvokeAsync()
(not blocking, but I didn't have a handle to dialog elements)