web

Provides methods for browser automation.

Notes:
Commands which operate on elements such as click, assert, waitFor, type, select, and others willautomatically wait for a period of time for the element to appear in DOM and become visible. Bydefault this period equals to 60 seconds, but can be changed using the setTimeoutcommand.

Commands which expect a string matching pattern in their arguments, support following patterns unless specified otherwise:
  • regex:PATTERN - Match using regular expression.
  • regexi:PATTERN - Match using case-insensitive regular expression.
  • exact:STRING - Match the string verbatim.
  • glob:PATTERN - Match using case-insensitive glob pattern. ? will match any single character except new line (\n). * will match any sequence (0 or more) of characters except new line. Empty PATTERN will match only other empty strings.
  • PATTERN - Same as glob matching.
Commands which expect an element locator in their arguments, support following locator types unless specified otherwise:
  • id=ID - Locates element by its ID attribute.
  • css=CSS_SELECTOR - Locates element using a CSS selector.
  • link=TEXT - Locates link element whose visible text matches the given string.
  • name=NAME - Locates element by its NAME attribute.
  • xpath=XPATH - Locates element using an XPath 1.0 expression.
  • /XPATH - Same as xpath=XPATH

Methods

getCaps()→ {Object}

Returns currently defined capabilities.
Returns:
Object - capabilities - Current capabilities object.

init(caps, seleniumUrl)

Initializes new Selenium session.

Initializes new Selenium session with provided desired capabilities.
Parameters:
Name Type Description
caps String optionalDesired capabilities. If not specified capabilities will be taken from suite definition.
seleniumUrl String optionalRemote server URL (default: http://localhost:4444/wd/hub).

transaction(name)

Opens new transaction.

The transaction will persist till a new one is opened. Transaction names must be unique.
Parameters:
Name Type Description
name String The transaction name.

dispose()

Ends the current session.

alertAccept()

Accepts an alert or a confirmation dialog.

In case of an alert box this command is identical to alertDismiss.

alertDismiss()

Dismisses an alert or a confirmation dialog.

In case of an alert box this command is identical to alertAccept.

assertAlert(pattern, timeout)

Asserts whether alert matches the specified pattern and dismisses it.

Text pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
pattern String Text pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

assertElementPresent(locator)

Asserts whether element exists in the DOM.
Parameters:
Name Type Description
locator String An element locator.

assertSelectedLabel(locator, pattern, timeout)

Asserts text of the currently selected option in a drop-down list.

Assertion pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String The assertion pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

assertSelectedValue(locator, pattern, timeout)

Asserts value of the currently selected option in a drop-down list.

Assertion pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String The assertion pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

waitForText(locator, pattern, timeout)

Waits for inner text of the given element to match the specified pattern.

Text pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String Text pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

assertTextPresent(text)

Asserts whether the given text is present somewhere on the page. That is whether an element containing this text exists on the page.
Parameters:
Name Type Description
text String Text.

assertTitle(pattern, timeout)

Asserts the page title.

Assertion pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
pattern String The assertion pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

assertValue(locator, pattern, timeout)

Asserts element's value.

Value pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String Value pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

clear(locator)

Clear the value of an input field.
Parameters:
Name Type Description
locator String An element locator.

click(locator)

Clicks on an element.

If the click causes new page to load, the command waits for page to load before proceeding.
Parameters:
Name Type Description
locator String An element locator.

clickHidden(locator)

Clicks on a non-visible element.

If the click causes new page to load, the command waits for page to load before proceeding.
Parameters:
Name Type Description
locator String An element locator.

closeWindow()

Closes the currently active window.

deselect(selectLocator, optionLocator)

Deselects an option from multiple-choice drop-down list.

Option locator can be one of the following (No prefix is same as label matching):
  • label=STRING - Matches option based on the visible text.
  • value=STRING - Matches option based on its value.
  • index=STRING - Matches option based on its index. The index is 0-based.
Parameters:
Name Type Description
selectLocator String An element locator identifying a drop-down menu.
optionLocator String An option locator.

doubleClick(locator)

Double clicks on an element.
Parameters:
Name Type Description
locator String An element locator.

executeScript(script)→ {Object}

Executes JavaScript in the context of the currently selected frame or window.

If return value is null or there is no return value, null is returned.
Parameters:
Name Type Description
script String The JavaScript to execute.
Returns:
Object - The return value.

fileBrowse(locator, filepath)

Uploads a local file.
Parameters:
Name Type Description
locator String Locator for a input type=file element.
filepath String Path to a local file.

getAlertText()→ {String}

Gets the text displayed by an alert or confirm dialog.
Returns:
String - The alert's text.

getAttribute(locator, attribute)→ {String}

Returns the element's attribute.
Parameters:
Name Type Description
locator String An element locator.
attribute String The name of the attribute to retrieve.
Returns:
String - The attribute's value.

getCssValue(locator, propertyName)→ {String}

Returns the value of a CSS property of an element.
Parameters:
Name Type Description
locator String An element locator.
propertyName String CSS property name.
Returns:
String - CSS property value.

getElementCount(locator)→ {Integer}

Retrieves the count of elements matching the given locator.
Parameters:
Name Type Description
locator String Element locator.
Returns:
Integer - Element count or 0 if no elements were found.

getPageSource()→ {String}

Gets the source of the currently active window.
Returns:
String - The page source.

getText(locator)→ {String}

Returns the text (rendered text shown to the user) of an element.
Parameters:
Name Type Description
locator String An element locator.
Returns:
String - The element's text.

getValue(locator)→ {String}

Returns the (whitespace-trimmed) value of an input field. For checkbox/radio elements, the value will be "on" or "off".
Parameters:
Name Type Description
locator String An element locator.
Returns:
String - The value.

getWindowHandles()→ {undefined}

Gets handles of currently open windows.
Returns:
{0} - Array of all available window handles.

getXMLPageSource()→ {String}

Gets the source of the currently active window which displays text/xml page.
Returns:
String - The XML page source.

isAlertPresent()→ {String}

Gets the text displayed by an alert or confirm dialog.
Returns:
String - The alert's text.

isElementPresent(locator, timeout)→ {Boolean}

Checks if element is present in the DOM. Returns false if element was not found within the specified timeout.
Parameters:
Name Type Description
locator String An element locator.
timeout Integer Timeout in milliseconds to wait for element to appear.
Returns:
Boolean - True if element was found. False otherwise.

isElementVisible(locator, timeout)→ {Boolean}

Checks if element is present and visible. Returns false if element was not found or wasn't visible within the specified timeout.
Parameters:
Name Type Description
locator String An element locator.
timeout Integer Timeout in milliseconds to wait for element to appear.
Returns:
Boolean - True if element was found and it was visible. False otherwise.

makeVisible(locator)

Makes hidden element visible.

This a workaround command for situations which require manipulation of hidden elements, such as when using web.type command for file input fields which tend to be hidden.
Specifically makeVisible will apply following styles to the specified element:
  • visibility = 'visible'
  • height = '1px'
  • width = '1px'
  • opacity = 1
  • display='block'
Parameters:
Name Type Description
locator String An element locator. If multiple elements match the locator, visibility is applied to all.

open(url)

Opens an URL.

The open command waits for the page to load before proceeding.
Parameters:
Name Type Description
url String The URL to open; may be relative or absolute.

pause(ms)

Pauses test execution for given amount of milliseconds.
Parameters:
Name Type Description
ms Integer milliseconds to pause the execution.

point(locator, xoffset, yoffset)

Points the mouse cursor over the specified element.
Parameters:
Name Type Description
locator String An element locator.
xoffset Integer optionalX offset from the element.
yoffset Integer optionalY offset from the element.

scrollToElement(locator, yoffset)

Scrolls the page to the location of the specified element.

yOffset determines the offset from the specified element where to scroll to. It can be either a positive or a negative value.
Parameters:
Name Type Description
locator String An element locator.
yoffset Integer optionalY offset from the element.

select(selectLocator, optionLocator)

Selects an option from a drop-down list using an option locator. This command works with multiple-choice lists as well.

Option locator can be one of the following (No prefix is same as label matching):
  • label=STRING - Matches option based on the visible text.
  • value=STRING - Matches option based on its value.
  • index=STRING - Matches option based on its index. The index is 0-based.
Parameters:
Name Type Description
selectLocator String An element locator identifying a drop-down menu.
optionLocator String An option locator.

selectFrame(frameLocator)

Selects a frame within the current window.

Available frame locators:
  • relative=parent - Select parent frame.
  • relative=top - Select top window.
  • index=0 - Select frame by its 0-based index.
  • //XPATH - XPath expression relative to the top window which identifies the frame. Multiple XPaths can be concatenated using ;; to switch between nested frames.
Parameters:
Name Type Description
frameLocator String A locator identifying a frame or an iframe.

selectWindow(windowLocator)→ {String}

Selects window. Once window has been selected, all commands go to that window.

windowLocator can be:
  • title=TITLE - Switch to the first window which matches the specified title. TITLE can be any of the supported string matching patterns.
  • windowHandle - Switch to a window using its unique handle.
Parameters:
Name Type Description
windowLocator String optionalWindow locator. If not specified last opened window will be switched to.
Returns:
String - windowHandle of the previously selected window.

setTimeout(timeout)

Specifies the amount of time that Oxygen will wait for actions to complete.

This includes the open command, waitFor* commands, and all other commands which wait for elements to appear or become visible before operating on them.
If command wasn't able to complete within the specified period it will fail the test.
The default time-out is 60 seconds.
Parameters:
Name Type Description
timeout Integer A time-out in milliseconds.

setWindowSize(width, height)

Sets the size of the outer browser window.

To maximize the window set both width and height to 0.
Parameters:
Name Type Description
width Integer Width in pixels.
height Integer Height in pixels.

takeScreenshot()

Take a screenshot of the current page or screen.

type(locator, value)

Simulates keystroke events on the specified element, as though you typed the value key-by-key. Previous value if any will be cleared.

Refer to Key Codes for the list of supported raw keyboard key codes.


Example of typing a sequence of characters and pressing Enter afterwards.

web.type('id=someElement', 'hello world\uE007');
Parameters:
Name Type Description
locator String An element locator.
value String The value to type.

waitForElementPresent(locator, timeout)

Waits for element to become available in the DOM.

This command is identical to waitForExist.
Parameters:
Name Type Description
locator String An element locator.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

waitForExist(locator, timeout)

Waits for element to become available in the DOM.
Parameters:
Name Type Description
locator String An element locator.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

waitForNotText(locator, pattern, timeout)

Waits for inner text of the given element to stop matching the specified pattern.

Text pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String Text pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

waitForNotValue(locator, pattern)

Waits for input element's value to stop matching the specified pattern.

Value pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String Value pattern.

waitForText(locator, pattern, timeout)

Waits for inner text of the given element to match the specified pattern.

Text pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String Text pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

waitForValue(locator, pattern, timeout)

Waits for input element's value to match the specified pattern.

Value pattern can be any of the supported string matching patterns.
Parameters:
Name Type Description
locator String An element locator.
pattern String Value pattern.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

waitForVisible(locator, timeout)

Waits for element to become visible.
Parameters:
Name Type Description
locator String An element locator.
timeout Integer optionalTimeout in milliseconds. Default is 60 seconds.

waitForWindow(windowLocator, timeout)

Waits for a window to appear, but doesn't actually switches to it.

windowLocator can be:
  • title=TITLE - Wait for the first window which matches the specified title. TITLE can be any of the supported string matching patterns.
Parameters:
Name Type Description
windowLocator String A window locator.
timeout Integer Timeout in milliseconds.