HTML button click, stop window from opening

I have a PowerShell script that clicks a button.

$nextbtn = $fileUploadPage.ParsedHtml.getElementById("btnGetFile")

But it opens up an Internet Explorer window. Is there a way to stop this, and have the button clicked with in PowerShell?

When you click the button in a browser, is it opening the window? You are finding the button through DOM and clicking the button just like you would in the browser initiating the onClick code, so the assumption would be this would happen in a browser as well. The onClick code is most likely launching the secondary window doing a re-direction or opening a new tab.

No, when I click the button on the browser, it does not open a new Window. It just goes to the next page.

That onClick code is still sending you to a page, so it’s opening a browser to send you there. Get the page that is being opened and just open that directly rather than doing the button click.

I’m going directly to the URL from IE, and it’s working. Thanks.