Table of Contents

Class PopupWindowFinder

Namespace
OpenQA.Selenium.Support.UI
Assembly
WebDriver.Support.dll

Provides a mechanism by which the window handle of an invoked popup browser window may be determined.

public class PopupWindowFinder
Inheritance
PopupWindowFinder
Inherited Members

Examples

// Store the current window handle so you can switch back to the
// original window when you close the popup.
string current = driver.CurrentWindowHandle;
PopupWindowFinder finder = new PopupWindowFinder(driver);
string newHandle = finder.Click(driver.FindElement(By.LinkText("Open new window")));
driver.SwitchTo.Window(newHandle);

Constructors

PopupWindowFinder(IWebDriver)

Initializes a new instance of the PopupWindowFinder class.

public PopupWindowFinder(IWebDriver driver)

Parameters

driver IWebDriver

The IWebDriver instance that is used to manipulate the popup window.

Remarks

When using this constructor overload, the timeout will be 5 seconds, and the check for a new window will be performed every 250 milliseconds.

Exceptions

ArgumentNullException

If driver is null.

PopupWindowFinder(IWebDriver, TimeSpan)

Initializes a new instance of the PopupWindowFinder class with the specified timeout.

public PopupWindowFinder(IWebDriver driver, TimeSpan timeout)

Parameters

driver IWebDriver

The IWebDriver instance that is used to manipulate the popup window.

timeout TimeSpan

The TimeSpan representing the amount of time to wait for the popup window to appear.

Remarks

When using this constructor overload, the check for a new window will be performed every 250 milliseconds.

Exceptions

ArgumentNullException

If driver is null.

PopupWindowFinder(IWebDriver, TimeSpan, TimeSpan)

Initializes a new instance of the PopupWindowFinder class with the specified timeout and using the specified interval to check for the existence of the new window.

public PopupWindowFinder(IWebDriver driver, TimeSpan timeout, TimeSpan sleepInterval)

Parameters

driver IWebDriver

The IWebDriver instance that is used to manipulate the popup window.

timeout TimeSpan

The TimeSpan representing the amount of time to wait for the popup window to appear.

sleepInterval TimeSpan

The TimeSpan representing the amount of time to wait between checks of the available window handles.

Exceptions

ArgumentNullException

If driver is null.

Methods

Click(IWebElement)

Clicks on an element that is expected to trigger a popup browser window.

public string Click(IWebElement element)

Parameters

element IWebElement

The IWebElement that, when clicked, invokes the popup browser window.

Returns

string

The window handle of the popup browser window.

Exceptions

WebDriverTimeoutException

Thrown if no popup window appears within the specified timeout.

ArgumentNullException

Thrown if the element to click is null.

Invoke(Action)

Invokes a method that is expected to trigger a popup browser window.

public string Invoke(Action popupMethod)

Parameters

popupMethod Action

An Action that, when run, invokes the popup browser window.

Returns

string

The window handle of the popup browser window.

Exceptions

WebDriverTimeoutException

Thrown if no popup window appears within the specified timeout.

ArgumentNullException

Thrown if the action to invoke is null.