Interface IBrowser
A tab in an open Web browser.
public interface IBrowser : ITestObject, IWebDescriber, ITestObjectDescriber, ILocationInfoProvider
- Inherited Members
- Extension Methods
Remarks
To open a new browser tab, use: Launch(BrowserType).
To access a browser that is already open, use: Attach(BrowserDescription)
.Properties
NumberOfTabs
The number of currently open tabs in the browser.
uint NumberOfTabs { get; }
Property Value
OpenTitle
The browser's initial title when first opened.
string OpenTitle { get; }
Property Value
OpenUrl
The URL from which the browser is opened.
string OpenUrl { get; }
Property Value
Page
A test object representing the top-level document in the tab.
IPage Page { get; }
Property Value
Title
The browser title.
string Title { get; }
Property Value
URL
The browser URL.
string URL { get; }
Property Value
Version
Data regarding the browser version and type.
BrowserVersion Version { get; }
Property Value
Methods
Activate(bool)
Activates the tab of the browser in the window group and if the 'setFocus' parameter is true it clicks on it (windows only). If the 'setFocus' parameter is set on an unsupported OS, an error of type 'unexpectedParameterException' is returned.
void Activate(bool setFocus = true)
Parameters
setFocusboolDecides to click or not the browser after it is activated. Default value: true
Back()
Navigates to the previous page in the browser history list.
void Back()
Remarks
This method is identical to clicking the browser's Back button.
ClearCache()
Clears the browser cache.
void ClearCache()
Remarks
This method does not clear the browser's cookies. Use DeleteCookies() to delete the cookies.
Close()
Closes the browser window (or tab) that this test object represents.
void Close()
Remarks
Use the CloseAllTabs() method to close the currently open tab, all sibling tabs, and the parent browser window.
CloseAllTabs()
Closes all tabs (if any) and closes the browser window.
void CloseAllTabs()
Remarks
Use the Close() method to close only the currently open tab.
Limitation: Your Internet Explorer (IE) browser must be configured to "Always close all tabs". To do this, open two or more tabs in IE. Then close IE. In the message box that pops up, select the "Always close all tabs" option.
Note: This method is not supported on Chrome. Use the Close method instead.
DeleteCookies()
Deletes all cookies from the browser.
void DeleteCookies()
Remarks
This method does not clear the browser's cache. Use ClearCache() clear the cache.
DeleteCookies(string)
Deletes only cookies that originated from the browser source.
void DeleteCookies(string fromSource)
Parameters
fromSourcestringThe full or partial domain of the source. For example, entering MySite.com or MySite.net clears cookies only from the specified site, whereas entering MySite clears cookies from all related domains.
Describe<TChild>(IDescription)
Describes a child test object.
TChild Describe<TChild>(IDescription description) where TChild : class, ITestObject
Parameters
descriptionIDescriptionThe child test object description.
Returns
- TChild
The requested child test object with its description.
Type Parameters
TChildThe child test object type.
Remarks
The current instance test object is the parent of the returned test object. This test object is searched for only when an operation on this test object is invoked. This means that if the test object is not found in the application, this command will still succeed. In this case, an exception is thrown only when an operation is invoked.
Describe<TChild>(CSSDescription)
Describes a child test object using the provided CSS selector.
TChild Describe<TChild>(CSSDescription cssSelector) where TChild : class, IWebElement
Parameters
cssSelectorCSSDescriptionThe CSS selector query used to find the child test object
Returns
- TChild
The requested child test object with its description
Type Parameters
TChildThe child test object type
Remarks
The current instance test object is the parent of the returned test object. This test object is searched for only when an operation on this test object is invoked. This means that if the test object is not found in the application, this command will still succeed. In this case, an exception is thrown only when an operation is invoked.
Describe<TChild>(XPathDescription)
Describes a child test object using the provided XPath.
TChild Describe<TChild>(XPathDescription xpath) where TChild : class, IWebElement
Parameters
xpathXPathDescriptionThe XPath used to find the child test object.
Returns
- TChild
The requested child test object with its description.
Type Parameters
TChildThe child test object type.
Remarks
The current instance test object is the parent of the returned test object. This test object is searched for only when an operation on this test object is invoked. This means that if the test object is not found in the application, this command will still succeed. In this case, an exception is thrown only when an operation is invoked.
EmbedScript(string)
Runs this JavaScript each time a page or frame loads or refreshes in the browser.
void EmbedScript(string script)
Parameters
scriptstringThe full content of the JavaScript to embed.
Remarks
- The script remains embedded until you close the browser, or until the run session ends.
- Using this method to perform alert operations may result in unexpected behavior.
- To run this method, the security settings in your Web browser must be set to allow active scripting. Otherwise, steps using this method will fail.
Forward()
Navigates to the next page in the browser history list.
void Forward()
Remarks
This method is identical to clicking the browser's Forward button.
FullScreen()
Toggles the browser between full-screen mode and normal mode
void FullScreen()
FullScreen(FullScreenMode)
Controls the browser's full screen mode.
void FullScreen(FullScreenMode mode)
Parameters
modeFullScreenModeIndicates whether to set the browser to full screen or normal mode. Possible values: FullScreenMode
GetDialogText()
Returns the text displayed in a browser message box, such as an alert, confirmation, or prompt.
string GetDialogText()
Returns
GetSiblingTabs()
Returns a collection of tabs (Browser objects) that are siblings to the current tab (tabs located in the same window)
IBrowser[] GetSiblingTabs()
Returns
- IBrowser[]
The collection of sibling tabs as Browsers
HandleDialog(DialogButton)
Clicks a button on the alert, confirmation, or prompt message box.
void HandleDialog(DialogButton button = DialogButton.Ok)
Parameters
buttonDialogButtonThe button to click. Default: OK
HandleDialog(string)
Enters text in the browser's prompt message box and clicks the OK button.
void HandleDialog(string text)
Parameters
textstringThe text to enter in the edit field.
HasDialog()
Indicates whether the browser message box is currently open.
bool HasDialog()
Returns
Navigate(string)
Opens the specified URL in the browser.
void Navigate(string url)
Parameters
urlstringThe URL to open.
OpenNewTab()
Opens a new tab in the browser window.
void OpenNewTab()
Refresh()
Refreshes the current page.
void Refresh()
Remarks
This method is identical to clicking the browser's Refresh button.
ResizeTo(Size)
Resizes the browser window to a specific size.
void ResizeTo(Size size)
Parameters
sizeSizeThe browser window size in pixels.
ResizeTo(uint, uint)
Resizes the browser window to specific dimensions.
void ResizeTo(uint width, uint height)
Parameters
Sync()
Waits for the browser to complete the current navigation.
void Sync()
Remarks
You can use this method to instruct your test to wait until the browser is loaded.