Dan Hernandez
Dan Hernandez

Reputation: 11

How to open a new window without using a link on the page with WebDriver

Without clicking a link on the page I am wondering how I can

What I have tried to is run WebDriver.ExecuteScript("window.open(\"about:blank\", \"_blank\", 'width=300, height=250');"); and then WebDriver.Manage().Window.Maximize(); but I don't seem to have control of that window.

Upvotes: 0

Views: 53

Answers (1)

sparrow
sparrow

Reputation: 980

You have to switch the active window context to the newest window before you can send commands to it like this

driver.SwitchTo().Window(driver.WindowHandles.Last());

After that the commands should go to that window.

Upvotes: 1

Related Questions