Note that there are some explanatory texts on larger screens.

plurals
  1. POReference to Pop-up window in Windows Powershell
    primarykey
    data
    text
    <p>I am working on testing-automation for a website I'm working on. I am using windows powershell to create scripts to do this. My problem is I need to click a link that opens up another window, I need a reference to that window some how. </p> <pre><code>$ie = new-object -com "InternetExplorer.Application" $ie.navigate("http://localhost:4611") $ie.visible = $true $doc = $ie.document $link = $doc.getElementByID('link') </code></pre> <p>That is where I get a reference to the browser and the link. Then I click the link:</p> <pre><code>$link.click() </code></pre> <p>Which opens up a new window with things I need to test on it. How would I get a reference to this new window? It is not technically a child window of the first one. </p> <p>I have tried to set the click of the link to a reference like this but it doesn't work:</p> <pre><code>$test = new-object -com "InternetExplorer.Application" $test = $link.click() </code></pre> <p><strong>UPDATE:</strong> Here is the JavaScript function openwindow that gets called to open the window</p> <pre><code>function openwindow(url, name) { if (typeof openwindow.winrefs == 'undefined') { openwindow.winrefs = {}; } if (typeof openwindow.winrefs[name] == 'undefined' || openwindow.winrefs[name].closed) { openwindow.winrefs[name] = window.open(url, name, 'scrollbars=yes,menubar=no,height=515,width=700,resizable=no,toolbar=no,status=no'); } else { openwindow.winrefs[name].focus(); }; }; </code></pre> <p>The function gets called in a line of code that looks like this</p> <pre><code>column.For(i =&gt; "&lt;a href='" + link + i.id + "?status=new' target='pat" + i.id + "'id'enc' onclick='openwindow(this.href,this.target);return false'&gt; </code></pre> <p><strong>FINAL UPDATE:</strong> I ended up doing this slightly differently. I created a new Internet Explorer object and grabbed the href from the link and set all of the options and navigated to the window using powershell like the javascript does.</p> <pre><code>$ie2 = new-object -com "InternetExplorer" $ie2.visible = $true $ie2.menubar = $false $ie2.height = 515 $ie2.width = 700 $ie2.resizable = $false $link = $doc.getelementbyid('link') $url = $link.href $ie2.navigate($url) </code></pre> <p>I'd like to thank @scunliffe so much for helping me through this problem. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload