Table of Contents

Interface IBrowser

Namespace
HP.LFT.SDK.Web
Assembly
HP.LFT.SDK.dll

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

uint

OpenTitle

The browser's initial title when first opened.

string OpenTitle { get; }

Property Value

string

OpenUrl

The URL from which the browser is opened.

string OpenUrl { get; }

Property Value

string

Page

A test object representing the top-level document in the tab.

IPage Page { get; }

Property Value

IPage

Title

The browser title.

string Title { get; }

Property Value

string

URL

The browser URL.

string URL { get; }

Property Value

string

Version

Data regarding the browser version and type.

BrowserVersion Version { get; }

Property Value

BrowserVersion

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

setFocus bool

Decides 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

fromSource string

The 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

description IDescription

The child test object description.

Returns

TChild

The requested child test object with its description.

Type Parameters

TChild

The 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

cssSelector CSSDescription

The CSS selector query used to find the child test object

Returns

TChild

The requested child test object with its description

Type Parameters

TChild

The 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

xpath XPathDescription

The XPath used to find the child test object.

Returns

TChild

The requested child test object with its description.

Type Parameters

TChild

The 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

script string

The 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

mode FullScreenMode

Indicates 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

string

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

button DialogButton

The 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

text string

The text to enter in the edit field.

HasDialog()

Indicates whether the browser message box is currently open.

bool HasDialog()

Returns

bool

Navigate(string)

Opens the specified URL in the browser.

void Navigate(string url)

Parameters

url string

The 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

size Size

The browser window size in pixels.

ResizeTo(uint, uint)

Resizes the browser window to specific dimensions.

void ResizeTo(uint width, uint height)

Parameters

width uint

The width of the browser window.

height uint

The height of the browser window.

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.