MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / NewWindow

Method NewWindow

dotnet/src/webdriver/TargetLocator.cs:187–199  ·  view source on GitHub ↗

Creates a new browser window and switches the focus for future commands of this driver to the new window. The type of new browser window to be created. The created window is not guaranteed to be of the requested type; if the driver does not support the requested type, a new browser window will be created of whatever type the driver does support.

(WindowType typeHint)

Source from the content-addressed store, hash-verified

185 /// will be created of whatever type the driver does support.</param>
186 /// <returns>An <see cref="IWebDriver"/> instance focused on the new browser.</returns>
187 public IWebDriver NewWindow(WindowType typeHint)
188 {
189 Dictionary<string, object?> parameters = new Dictionary<string, object?>();
190 parameters.Add("type", typeHint.ToString().ToLowerInvariant());
191
192 Response response = this.driver.Execute(DriverCommand.NewWindow, parameters);
193
194 Dictionary<string, object> result = (Dictionary<string, object>)response.Value!;
195 string newWindowHandle = result["handle"].ToString()!;
196 this.Window(newWindowHandle);
197
198 return this.driver;
199 }
200
201 /// <summary>
202 /// Change the active frame to the default

Calls 4

WindowMethod · 0.95
AddMethod · 0.45
ToStringMethod · 0.45
ExecuteMethod · 0.45