Since: API Level v2
public abstract class

WebDriverPluginShare

com.webmbt.plugin.WebDriverPluginShare
Known Direct Subclasses

Class Overview

WebDriver / Selenium plugin ancestor that contains implementats of shared methods. Only used by Selenium plugin which will be changed to call SeleniumHelper.

Copyright © 2009 - 2017 TestOptimal LLC. All Rights Reserved.

Summary

Public Constructors
WebDriverPluginShare()
Public Methods
String WebDriver(String... params_p)
calls a method in org.openqa.selenium.WebDriver class that accepts String parameter(s) or no parameters.
String[] WebDriverElement(String... params_p)
calls a method in org.openqa.selenium.WebElement class that accepts String parameter(s) or no parameters.
String WebDriverManage(String... params_p)
calls a method in org.openqa.selenium.WebDriver.Options class that accepts String parameter(s) or no parameters.
String WebDriverNavigate(String... params_p)
calls a method in org.openqa.selenium.WebDriver.Navigation class that accepts String parameter(s) or no parameters.
String WebDriverSwitchTo(String... params_p)
calls a method in org.openqa.selenium.WebDriver.TargetLocator class that accepts String parameter(s) or no parameters.
void acceptAlert()
accept the alert dialog window by clicking on "OK" button.
void clear(String locator_p)
clears the input field.
void click(String locator_p, String coordX_p, String coordY_p)
simulate click on the first element found.
void click(String locator_p)
simulate click on the first element found.
void click(String locator_p, String shiftCtrlAlt_p)
simulate click on the first element found with option of holding down shift, ctrl or alt key.
void closeWindow(String windowName_p)
closes a window
boolean containsText(String text_p)
returns true if current page contains the text passed in.
boolean containsText(String loc_p, String text_p)
returns true if the element of the locator passed in contains the text specified.
int count(String locator_p)
returns count of number of objects for the element locator passed in.
void dismissAlert()
dismiss the alert/confirm dialog by clicking on close or "cancel" button.
void doubleClick(String locator_p)
double click on the first element found.
void dragAndDrop(String fromLocator_p, String toLocator_p)
drag an element and drop it onto another element.
String getAlertText()
String getAllWindows()
return the information of all windows currently open.
String[] getAllWindowsID()
returns a list of window handles.@return
String[] getAttr(String locator_p, String attrName_p)
Returns the value of HTML attribute value defined in the element.
String getBrowserType()
returns the type of browser currently being launched.
String getConfirmText()
returns the message in the confirm popup dialog if present.
String getCookie(String cookieName_p)
returns the value of the cookie.
Object getNativePluginObj()
returns the plugin native driver object, e.g.
String getPageText()
returns the text representation of current webpage.
String[] getText(String locator_p)
Returns the text of the element.
String getTitle()
returns the title of the current window/page.
String[] getValue(String locator_p)
Returns the value of the first element found with the locator_p.
void highlightElement(String locator_p, String color_p, String millis_p)
highlight element(s) by changing its border color temporarily for a duration specified in milliseconds.
void highlightElement(String locator_p)
highlights the element identified the locator passe in for 1 second by drawing an orange border around the element.
boolean isAlertPresent()
retusn true if the alert dialog has been displayed(triggered).
boolean isChecked(String locator_p)
returns true if the first element found with locator_p is checked: radio button or checkbox only.
boolean isConfirmPresent()
retusn true if the confirm dialog has been displayed(triggered).
boolean isDisabled(String locator_p)
returns true if any of the elements found is disabled.
boolean isPresent(String locator_p)
returns true if the element exists in the current page/frame/window.
boolean isVisible(String locator_p)
returns true if any of the elements is visible.
String js(String javascript_p)
executes javascript on current window/frame.
String[] listIFrames()
returns a list of frame names of current window
String locate(String loc_p)
locates the element and pass back the local locator that can be used by selenium native method.
void mouseDown(String locator_p)
trigger mouse down event on the first element found for locator_p.
void mouseOver(String locator_p)
trigger mouse over event on the first element found for locator_p.
void mouseUp(String locator_p)
trigger mouse up event on the first element found for locator_p.
void openURL(String url_p)
navigate to url specified.
void openWindow(String url_p, String winName_p)
opens a new browser window but leave existing windows open.
void refresh()
click on the browser refresh button.
void resetMainEveryLocator(String resetFlag_p)
to instruct Selenium plugin to reset the current target window to the default main window or first frame if window contains frameset.
void restartBrowser(String url_p)
closes all browser windows if any and opens a new browser window at the url passed in.
void rightClick(String locator_p)
rightClick on the first element found with locator_p.
void scrollBy(String x_delta_p, String y_delta_p)
scrolls window by the x and y pixels specified.
void scrollTo(String x_p, String y_p)
scrolls window to the x,y coordinates specified.
void selectFrame(String frameName_p)
This method is deprecated. rel. 4.0, use locator syntax 'frame=xxx;myLoc' where xxx is the name of the frame or 0-based index of the frame (iframe).
void selectOption(String locator_p, String optionLocator_p)
selects an option for the Select element.
void selectWindow(String windowName_p)
selects a specified window as the current target window which all future commands to be directed to.
void sendKey(String locator_p, String keyString_p)
type the string to the first element found with locator_p.
void setBrowserCmd(String browserCmd_p)
changes the browser to be used for executing mbt.
void setCapabilityBoolean(String capKey_p, String capVal_p)
void setCapabilityInteger(String capKey_p, String capVal_p)
void setCapabilityList(String capKey_p, String capVal_p, String delChar_p)
void setCapabilityLong(String capKey_p, String capVal_p)
void setCapabilityString(String capKey_p, String capVal_p)
sets a capability setting for the selected browser.
void setCheckBox(String locator_p, String checked_p)
sets the checkbox.
void setImplicitWait(String millis_p)
sets the implicitWait parameter for WebDriver.
void setProxy(String proxyURL_p)
sets the proxy server url for webdriver
void setRadioButton(String locator_p, String checked_p)
sets the first radio button found with locator_p.
void setWindowMaximized()
maximizes the browser window.
void setWindowPosition(String left_p, String top_p)
sets the window home position.
void setWindowSize(String width_p, String height_p)
sets the browser window size to the specified dimension: width and height.
int sizeOf(String locator_p)
returns the number options in the first select element found
String snapScreen(String fn_p)
Take a snapshot of current AUT window.
void type(String locator_p, String shiftCtrlAlt_p, String keyString_p)
type the string to the first element found with locator_p with the option to have shift/control/alt key pressed.
void type(String locator_p, String keyString_p)
type the string to the first element found with locator_p.
void typeKeys(String locator_p, String keyString_p)
type the string to the first element found with locator_p.
boolean waitForCondition(String locator_p, String condType_p, String condResult_p, String timeoutMillis_p)
waits for a condition specified on the element up to the specified timeout in milliseconds.
boolean waitForElement(String locator_p, String timeoutMillis_p)
waits for an element to be visible up to the specified timeout in milliseconds.
boolean waitForWindow(String winName_p, String timeoutMillis_p)
waits for a window to open/appear up to the specified timeout in milliseconds.
boolean windowExists(String winNameTitle_p)
returns true if the window with specified name/title is found.

Public Constructors

public WebDriverPluginShare ()

Since: API Level v2

Public Methods

public String WebDriver (String... params_p)

Since: API Level v2

calls a method in org.openqa.selenium.WebDriver class that accepts String parameter(s) or no parameters.

Example:

$WebDriver('getPageSource')
The above expression calls org.openqa.selenium.WebDriver.getPageSource().@return

Parameters
params_p 0, 1 or many parameters
Throws
MBTException

public String[] WebDriverElement (String... params_p)

Since: API Level v2

calls a method in org.openqa.selenium.WebElement class that accepts String parameter(s) or no parameters.

Example:

$WebDriverElement('id=f1','click')
The above expression calls org.openqa.selenium.WebElement.click()@return

Parameters
params_p String parameters
Throws
MBTException
MBTException

public String WebDriverManage (String... params_p)

Since: API Level v2

calls a method in org.openqa.selenium.WebDriver.Options class that accepts String parameter(s) or no parameters.

Example:

$WebDriverManage('getCookieNamed','xyz')
The above expression calls org.openqa.selenium.WebDriver.Options.getCookieNamed("xyz") returns the cookie value.@return

Throws
MBTException
MBTException

public String WebDriverNavigate (String... params_p)

Since: API Level v2

calls a method in org.openqa.selenium.WebDriver.Navigation class that accepts String parameter(s) or no parameters.

Example:

$WebDriverNavigate('back')
The above expression calls org.openqa.selenium.WebDriver.Navigation.back()@return

Throws
MBTException
MBTException

public String WebDriverSwitchTo (String... params_p)

Since: API Level v2

calls a method in org.openqa.selenium.WebDriver.TargetLocator class that accepts String parameter(s) or no parameters.

Example:

$WebDriverSwitchTo('frame','ABC')
The above expression calls org.openqa.selenium.WebDriver.TargetLocator.frame("ABC")@return

Throws
MBTException
MBTException

public void acceptAlert ()

Since: API Level v2

accept the alert dialog window by clicking on "OK" button.

Throws
MBTException

public void clear (String locator_p)

Since: API Level v2

clears the input field.

Example:

<action code="$clear('id=F1')"/> 

Throws
MBTException

public void click (String locator_p, String coordX_p, String coordY_p)

Since: API Level v2

simulate click on the first element found. Element must supports coordinates, for example an image.

Example:

<action code="$click('id=F1','100','200')"/> 

Notice that even though coordX_p and coordY_p are integer parameters, they must be enclosed by a set of single quote.

Throws
MBTException

public void click (String locator_p)

Since: API Level v2

simulate click on the first element found.

Example:

<action code="$click('id=F1')"/> 

Throws
MBTException

public void click (String locator_p, String shiftCtrlAlt_p)

Since: API Level v2

simulate click on the first element found with option of holding down shift, ctrl or alt key.

Not available for remote testing using selenium/appium/saucelabs servers.

Example:

<action code="$click('id=F1','S')"/> 

Throws
MBTException

public void closeWindow (String windowName_p)

Since: API Level v2

closes a window

Throws
MBTException

public boolean containsText (String text_p)

Since: API Level v2

returns true if current page contains the text passed in. The text must be static text string only.

Example:

<log msg="Page contains text XXXX? $containsText('XXXX')"/> 

Webapp only.

Throws
MBTException

public boolean containsText (String loc_p, String text_p)

Since: API Level v2

returns true if the element of the locator passed in contains the text specified. The text must be static text string only.

Example:

<log msg="Page contains text XXXX? $containsText('id=xyz', 'XXXX')"/>

Throws
MBTException

public int count (String locator_p)

Since: API Level v2

returns count of number of objects for the element locator passed in.

Example:

<log msg="$found $count('name=paymentType') payment types on the screen"/>

Throws
MBTException

public void dismissAlert ()

Since: API Level v2

dismiss the alert/confirm dialog by clicking on close or "cancel" button.

Throws
MBTException

public void doubleClick (String locator_p)

Since: API Level v2

double click on the first element found.

Example:

<action code="$doubleClick('id=F1')"/>

Throws
MBTException

public void dragAndDrop (String fromLocator_p, String toLocator_p)

Since: API Level v2

drag an element and drop it onto another element. Only the first element found for both drag source and drop source locators are acted on.

Example:

<action code="$dragAndDrop('id=F1','id=f2')"/> 
The above MScript drags element F1 and drops it on the element f2.

Parameters
fromLocator_p element locator
toLocator_p element locator
Throws
MBTException

public String getAlertText ()

Since: API Level v2

Throws
MBTException

public String getAllWindows ()

Since: API Level v2

return the information of all windows currently open.

Each window is described in the following format, multiple windows are separated with a semi-colon ";". :
name:title[idx]

public String[] getAllWindowsID ()

Since: API Level v2

returns a list of window handles.@return

Throws
MBTException
MBTException
See Also

public String[] getAttr (String locator_p, String attrName_p)

Since: API Level v2

Returns the value of HTML attribute value defined in the element.

Example:

<log msg="Field attribute: $getAttr('id=F1','class')."/>

Each type of HTML element has a set of attributes but it also allows user defined attributes. For example "table" element has these attributes "id", "name", "width", "height", "class", etc. These are standard attributes to define a table in HTML. You may add any user attributes like "customerNumber", "orderNumber", "firstName", etc. These user defined attributes are also accessible by getAttr().

Throws
MBTException
See Also
  • http://www.w3schools.com/tags/default.asp

public String getBrowserType ()

Since: API Level v2

returns the type of browser currently being launched. This is thread specific. That is, a model running multiple threads each thread can launch different browser.@return

Throws
MBTException

public String getConfirmText ()

Since: API Level v2

returns the message in the confirm popup dialog if present. blank if not.@return

Throws
MBTException

public String getCookie (String cookieName_p)

Since: API Level v2

returns the value of the cookie.

Throws
MBTException

public Object getNativePluginObj ()

Since: API Level v2

returns the plugin native driver object, e.g. selenium returns selenium webdriver object. Not an MScript function. For use in java handler only.

public String getPageText ()

Since: API Level v2

returns the text representation of current webpage. Webapp only

Returns
  • text string that represents the current page.
Throws
MBTException
MBTException

public String[] getText (String locator_p)

Since: API Level v2

Returns the text of the element. If multiple elements found, return a String with all text strung together separated by semicolon.

Example:

<log msg="$getText('id=rowTitle')"/> 

Throws
MBTException

public String getTitle ()

Since: API Level v2

returns the title of the current window/page.

Example:

<log msg="Page title is: $getTitle()"/>

Throws
MBTException

public String[] getValue (String locator_p)

Since: API Level v2

Returns the value of the first element found with the locator_p. If element does not have value attribute, it returns the text. If element still does not have text attribute, it returns blank.

Example:

<log msg="userid is: $getValue('userid')"/>

Throws
MBTException

public void highlightElement (String locator_p, String color_p, String millis_p)

Since: API Level v2

highlight element(s) by changing its border color temporarily for a duration specified in milliseconds. webapp only.

Parameters
color_p html color code
millis_p number of milliseconds, 0 for leaving the highlight (note this may affect your application behavior due to style attribute changed)
Throws
Exception

public void highlightElement (String locator_p)

Since: API Level v2

highlights the element identified the locator passe in for 1 second by drawing an orange border around the element.

Throws
Exception

public boolean isAlertPresent ()

Since: API Level v2

retusn true if the alert dialog has been displayed(triggered).

Throws
MBTException

public boolean isChecked (String locator_p)

Since: API Level v2

returns true if the first element found with locator_p is checked: radio button or checkbox only.

Example:

<log msg="The checkbox F1 checked? $isChecked('id=F1')"/>

Parameters
locator_p locator to the checkbox
Throws
MBTException

public boolean isConfirmPresent ()

Since: API Level v2

retusn true if the confirm dialog has been displayed(triggered). isConfirmPresent() must be called immediately after the action that trigger the confirm popup. optionally you can call getConfirmText().

Throws
MBTException

public boolean isDisabled (String locator_p)

Since: API Level v2

returns true if any of the elements found is disabled.

Example:

<log msg="Field F1 disabled?: $isDisabled('id=F1')."/>

Throws
MBTException

public boolean isPresent (String locator_p)

Since: API Level v2

returns true if the element exists in the current page/frame/window. Invisible elements are considered present.

Example:

<if val1="$isPresent('checkbox1')" op="eq" val2="true"/> 
    <log msg="checkbox1 is present on this page">
</if>

Throws
MBTException

public boolean isVisible (String locator_p)

Since: API Level v2

returns true if any of the elements is visible.

Example:

<log msg="Field F1 visible?: $isVisible('id=F1')."/> 

Throws
MBTException

public String js (String javascript_p)

Since: API Level v2

executes javascript on current window/frame. Be sure to use "return xyz" if you wish to receive the return from the call.@return

Throws
MBTException

public String[] listIFrames ()

Since: API Level v2

returns a list of frame names of current window

public String locate (String loc_p)

Since: API Level v2

locates the element and pass back the local locator that can be used by selenium native method. This method should only be used inside the parameter of the native method call.

Example:

$_keyPress('$locate('frame=abc;xpath=id(\'id123\')', 'A') which set the focus
to the frame abc and passes xpath=id(\'id123\') to $_keyPress('xpath=id(\'id123\')', 'A')@return

Throws
MBTException

public void mouseDown (String locator_p)

Since: API Level v2

trigger mouse down event on the first element found for locator_p.

Example:

<action code="$mouseDown('id=F1')"/> 

Throws
MBTException

public void mouseOver (String locator_p)

Since: API Level v2

trigger mouse over event on the first element found for locator_p.

Example:

<action code="$mouseOver('id=F1')"/> 

Throws
MBTException

public void mouseUp (String locator_p)

Since: API Level v2

trigger mouse up event on the first element found for locator_p.

Example:

<action code="$mouseUp('id=F1')"/>

Throws
MBTException

public void openURL (String url_p)

Since: API Level

navigate to url specified. Example:

$openURL('http://google.com/')

Throws
Exception

public void openWindow (String url_p, String winName_p)

Since: API Level v2

opens a new browser window but leave existing windows open. You may use $selectWindow() to go back to other window.

Parameters
url_p url to open
winName_p name to be assigned to the window
Throws
Exception

public void refresh ()

Since: API Level v2

click on the browser refresh button.

Example:

<action code="$refresh()"/> 

Throws
MBTException

public void resetMainEveryLocator (String resetFlag_p)

Since: API Level v2

to instruct Selenium plugin to reset the current target window to the default main window or first frame if window contains frameset.

Call this method with "false" to avoid constantly resetting the current target window context for better performance, but be aware that you will need to adjust your locators accordingly and call $selectWindow('') if you need redirect current target window to the main window.

public void restartBrowser (String url_p)

Since: API Level v2

closes all browser windows if any and opens a new browser window at the url passed in.

Parameters
url_p url or blank to open the browser at the model's appURL
Throws
Exception

public void rightClick (String locator_p)

Since: API Level v2

rightClick on the first element found with locator_p.

Example:

<action code="$rightClick('id=F1')"/> 

Throws
MBTException

public void scrollBy (String x_delta_p, String y_delta_p)

Since: API Level v2

scrolls window by the x and y pixels specified. Use negative number to scroll backwards. webapp only.

Parameters
x_delta_p integer, amount to scroll on x coordinate (horizontal axis), specify '' or '0' for no change.
y_delta_p integer, amount to scroll on y coordinate (vertical axis), specify '' or '0' for no change.
Throws
MBTException

public void scrollTo (String x_p, String y_p)

Since: API Level v2

scrolls window to the x,y coordinates specified. Upper-left corner is (0,0). webapp only.

Parameters
x_p integer, x coordinate (horizontal)
y_p integer, y coordinate (vertical)
Throws
MBTException

public void selectFrame (String frameName_p)

Since: API Level v2

This method is deprecated.
rel. 4.0, use locator syntax 'frame=xxx;myLoc' where xxx is the name of the frame or 0-based index of the frame (iframe).

select the named frame as the current default frame.

Example:

<action code="$selectFrame('frame1')"/> 

Parameters
frameName_p name of the frame
Throws
MBTException

public void selectOption (String locator_p, String optionLocator_p)

Since: API Level v2

selects an option for the Select element.

Example:

<action code="$selectOption('id=selectF1','value=2')"/> 

Parameters
locator_p locator for the element
optionLocator_p locator for the option to be selected.
  • label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)

    For example, label=regexp:^[Oo]ther

  • value=valuePattern: matches options based on their values.

    For example, value=other

  • id=id: matches options based on their ids.

    id=option1

  • index=index: matches an option based on its index (offset from zero).

    index=2

Throws
MBTException

public void selectWindow (String windowName_p)

Since: API Level v2

selects a specified window as the current target window which all future commands to be directed to. Pass empty string for the window name to reset current target window to the main window.

You may also select window by window title (rel 4.0.8).

Example:

<action code="$selectWindow('mainWin')"/> 

Parameters
windowName_p name of the window, pass empty string for main window. You may pass in an integer (1-based) to select window by its index or regular expression with syntax /regExpr/ or use suffix/prefix "*" for startsWith and endsWith.
Throws
MBTException

public void sendKey (String locator_p, String keyString_p)

Since: API Level v2

type the string to the first element found with locator_p. The element must be an input field. It does not clear the content/value of the element if it's not empty.

Example:

<action code="$sendKey('id=F1','abc')"/>

Use the following tokens to simulate special keyboard key:

  • [KEYS.BACK_SPACE]
  • [KEYS.TAB]
  • [KEYS.CLEAR]
  • [KEYS.RETURN]
  • [KEYS.ENTER]
  • [KEYS.SHIFT]
  • [KEYS.LEFT_SHIFT]
  • [KEYS.CONTROL]
  • [KEYS.LEFT_CONTROL]
  • [KEYS.ALT]
  • [KEYS.LEFT_ALT]
  • [KEYS.PAUSE]
  • [KEYS.ESCAPE]
  • [KEYS.SPACE]
  • [KEYS.PAGE_UP]
  • [KEYS.PAGE_DOWN]
  • [KEYS.END]
  • [KEYS.HOME]
  • [KEYS.LEFT]
  • [KEYS.ARROW_LEFT]
  • [KEYS.UP]
  • [KEYS.ARROW_UP]
  • [KEYS.RIGHT]
  • [KEYS.ARROW_RIGHT]
  • [KEYS.NULL]
  • [KEYS.CANCEL]
  • [KEYS.HELP]
  • [KEYS.BACK_SPACE]
  • [KEYS.DOWN]
  • [KEYS.ARROW_DOWN]
  • [KEYS.INSERT]
  • [KEYS.DELETE]
  • [KEYS.SEMICOLON]
  • [KEYS.EQUALS]
  • [KEYS.NUMPAD0]
  • [KEYS.NUMPAD1]
  • [KEYS.NUMPAD2]
  • [KEYS.NUMPAD3]
  • [KEYS.NUMPAD4]
  • [KEYS.NUMPAD5]
  • [KEYS.NUMPAD6]
  • [KEYS.NUMPAD7]
  • [KEYS.NUMPAD8]
  • [KEYS.NUMPAD9]
  • [KEYS.MULTIPLY]
  • [KEYS.ADD]
  • [KEYS.SEPARATOR]
  • [KEYS.SUBTRACT]
  • [KEYS.DECIMAL]
  • [KEYS.DIVIDE]
  • [KEYS.F1]
  • [KEYS.F2]
  • [KEYS.F3]
  • [KEYS.F4]
  • [KEYS.F5]
  • [KEYS.F6]
  • [KEYS.F7]
  • [KEYS.F8]
  • [KEYS.F9]
  • [KEYS.F10]
  • [KEYS.F11]
  • [KEYS.F12]
  • [KEYS.META]
  • [KEYS.COMMAND]
  • [KEYS.ZENKAKU_HANKAKU]
Key token must be used alone or attached to the end of the string. For example, $sendKey('id=field1','[KEYS.ENTER]') or $sendKey('id=field1','abc[KEYS.TAB]')

Throws
MBTException
See Also
  • type(loc, keyString)

public void setBrowserCmd (String browserCmd_p)

Since: API Level v2

changes the browser to be used for executing mbt. Should only be called in MBT_start trigger.

You may use a dataset to store a list of browser start cmds and randomly retrieve one to set for each virtual users to simulate multiple users using different browsers.

For example, you can use $nextDataSetRow(java.lang.String dataSetID_p, java.lang.String floatIdx_p), $rand(), and $getData('ds','field') to retrieve different browser "cmd" from a file/spreadsheet to achieve testing with virtual users with each running different browser, like
<action code="$nextDataSetRow('myDS', '$rand()')"/>
<action code="$setBrowserCmd('$getData('myDS', 'myField')')"/>

The alternative is to use DataGen plugin to randomly choose a browser from the list of browsers specified.

Example:

$setBrwoserCmd('$randFromList('internetExplorer|firefox|Chrome')')

Parameters
browserCmd_p legal Selenium browser start cmd including custom browser start cmd. If blank is passed in, it will not change the browser.

For example iexplore for IE, firefox for Firefox, custom c:/xxxx/yy.exe for custom browser to run a specific exe.

s

public void setCapabilityBoolean (String capKey_p, String capVal_p)

Since: API Level v2

public void setCapabilityInteger (String capKey_p, String capVal_p)

Since: API Level v2

public void setCapabilityList (String capKey_p, String capVal_p, String delChar_p)

Since: API Level v2

public void setCapabilityLong (String capKey_p, String capVal_p)

Since: API Level v2

public void setCapabilityString (String capKey_p, String capVal_p)

Since: API Level v2

sets a capability setting for the selected browser. Must supply the exact key and value in an appropriate format. This method is only valid in MBT_start trigger. Calling this method outside MBT_start trigger has no effect.

This method has variations for different data type. Choose the correct variation that is appropriate for the capability setting according to the browser's specific requirement.

For more information about capability setting supported by the specific browser, please visit WebDriver support page at: http://code.google.com/p/selenium/wiki

Optionally you can set capabilities by editing webdriver.properties in Config folder.

public void setCheckBox (String locator_p, String checked_p)

Since: API Level v2

sets the checkbox.

Example:

<action code="$setCheckBox('id=F1','true')"/> 

Parameters
locator_p locator to the checkbox element
checked_p true or false
Throws
MBTException

public void setImplicitWait (String millis_p)

Since: API Level v2

sets the implicitWait parameter for WebDriver. Implicit wait is the maximun amount of WebDriver will wait for the element to appear in the document. This setting applies to WebDriver directly and is used for all operations that require finding an element in the document.

You may need to use other wait method to supplement this global setting to meet specific needs in different part of the model.

Parameters
millis_p number of milliseconds

public void setProxy (String proxyURL_p)

Since: API Level v2

sets the proxy server url for webdriver

public void setRadioButton (String locator_p, String checked_p)

Since: API Level v2

sets the first radio button found with locator_p.

Example:

<action code="$setRadioButton('id=F1','true')"/> 

Parameters
locator_p locator to the radiobutton element
checked_p true or false
Throws
MBTException

public void setWindowMaximized ()

Since: API Level v2

maximizes the browser window.

Example:

$setWindowMaximized()

public void setWindowPosition (String left_p, String top_p)

Since: API Level v2

sets the window home position. Typically you would call this method in MBT_start trigger to position the browser at the desired position.

Example:

$setWindowPosition('100', '400')

public void setWindowSize (String width_p, String height_p)

Since: API Level v2

sets the browser window size to the specified dimension: width and height. Inavalid width or height value will default to 1000.

Example:

$setWindowSize('1000','2000')

public int sizeOf (String locator_p)

Since: API Level v2

returns the number options in the first select element found

Throws
MBTException

public String snapScreen (String fn_p)

Since: API Level v2

Take a snapshot of current AUT window.

Typical use of this method is to call it in or trigger to take a snapshot of the screen of the error.

The screen shot will be marked with the first exception (if multiple exceptions) triggered by current mScript and thus available from the exception popup.

Example:

<action code="$Selenium.snapScreen('myFileName')"/>

Returns
  • file path of the screen shot file
Throws
Exception

public void type (String locator_p, String shiftCtrlAlt_p, String keyString_p)

Since: API Level v2

type the string to the first element found with locator_p with the option to have shift/control/alt key pressed. It clears the current value before issuing typing the string into the field.

Not available for remote testing using selenium/appium/saucelabs servers.

Example:

<action code="$type('id=F1','S','abc')"/> 

Parameters
shiftCtrlAlt_p include char "c" for control key, "a" for alt key and "s" for shift key. For example "cs" to have control and shift keys pressed.
Throws
MBTException
MBTException
See Also
  • sendKey(loc, keystring)

public void type (String locator_p, String keyString_p)

Since: API Level v2

type the string to the first element found with locator_p. The element must be an input field. It clears the current value before issuing typing the string into the field.

Example:

<action code="$type('id=F1','abc')"/> 

Parameters
locator_p element locator
keyString_p string to be typed into the field. You may use key token as described in sendKey(loc, keyString) function to enter special keyboar key.
Throws
MBTException
See Also
  • sendKey(loc, keystring)

public void typeKeys (String locator_p, String keyString_p)

Since: API Level v2

type the string to the first element found with locator_p. The element must be an input field. It does not clear the content/value of the element if it's not empty. This is equivalent to sendKey().

Example:

<action code="$sendKey('id=F1','abc')"/> 

Throws
MBTException
See Also
  • sendKey(locator, keyString)
  • typeKey(locator, keyString)
  • type(locator, keyString)

public boolean waitForCondition (String locator_p, String condType_p, String condResult_p, String timeoutMillis_p)

Since: API Level v2

waits for a condition specified on the element up to the specified timeout in milliseconds. Returns true if the condition becomes true, false if it times out.

Parameters
condType_p text, visible, enabled or name of the attribute e.g. 'class', 'style', 'width', etc.
condResult_p expected state/value of the found element. e.g. for 'text' type, specify the expected string or regular expression, for 'visible' type, specify true or false, etc.
Returns
  • true if condition is found to be true within timeout duration, else return false.
Throws
MBTException

public boolean waitForElement (String locator_p, String timeoutMillis_p)

Since: API Level v2

waits for an element to be visible up to the specified timeout in milliseconds. Returns true if the element is found, false it times out.

Returns
  • true if element is found
Throws
MBTException

public boolean waitForWindow (String winName_p, String timeoutMillis_p)

Since: API Level v2

waits for a window to open/appear up to the specified timeout in milliseconds. Returns true if the window is found, false it times out waiting.

Parameters
winName_p name of the window or window handle (obtained with $getAllWindows()
Returns
  • true if element is found
Throws
MBTException

public boolean windowExists (String winNameTitle_p)

Since: API Level v2

returns true if the window with specified name/title is found. Else return false.

Parameters
winNameTitle_p name of the window, pass empty string for main window. You may pass in an integer (1-based) to select window by its index or regular expression with syntax /regExpr/ or use suffix/prefix "*" for startsWith and endsWith.