com.webmbt.plugin
Class SeleniumPlugin

java.lang.Object
  extended by com.webmbt.plugin.PluginAncestor
      extended by com.webmbt.plugin.WebPluginAncestor
          extended by com.webmbt.plugin.SeleniumPlugin
All Implemented Interfaces:
MScriptInterface, MScriptMethodIntf

public class SeleniumPlugin
extends WebPluginAncestor

Requires plugin parameters (in config).

  1. host - required, selenium host name, if localhost is specified, webmbt will start a pool of Selenium servers automatically.
  2. startPort - required, selenium port range start, usually set to 4444 (default selenium port number)
  3. endPort - required, selenium port range end, must be greater than startPort.
  4. shared/exculsive - optional, if multiple webmbt sessions can share the same selenium port. default is exclusive
  5. multiwindow/singlewindow - optional, if Selenium should start with -multiwindow. Default to singlewindow. This is only applicable for host = localhost.
  6. args:-xxx yyyy -aaa bbbb - Selenium server startup arguments
Example: com.webmbt.plugin.SeleniumPlugin,4444,4450,args:-singleWindow -timeout 1000 Selenium RC startup arguments:
  1. -port : DO NOT USE, the port number the selenium server should use (default 4444)
  2. -timeout : specifies the number of seconds that you allow data to wait all in the communications queues before an exception is thrown.
  3. -interactive: puts you into interactive mode. See the tutorial for more details
  4. -singleWindow: puts you into a mode where the test web site executes in a frame. This mode should only be selected if the application under test does not use frames.
  5. -profilesLocation: Specifies the directory that holds the profiles that java clients can use to start up selenium. Currently supported for Firefox only.
  6. -forcedBrowserMode : sets the browser mode to a single argument (e.g. \"*iexplore\") for all sessions, no matter what is passed to getNewBrowserSession
  7. -forcedBrowserModeRestOfLine : sets the browser mode to all the remaining tokens on the line (e.g. \"*custom /some/random/place/iexplore.exe\") for all sessions, no matter what is passed to getNewBrowserSession
  8. -userExtensions : indicates a JavaScript file that will be loaded into selenium
  9. -browserSessionReuse: stops re-initialization and spawning of the browser between tests
  10. -avoidProxy: By default, we proxy every browser request; set this flag to make the browser use our proxy only for URLs containing '/selenium-server'
  11. -firefoxProfileTemplate : normally, we generate a fresh empty Firefox profile every time we launch. You can specify a directory to make us copy your profile directory instead.
  12. -debug: puts you into debug mode, with more trace information and diagnostics on the console
  13. -browserSideLog: enables logging on the browser side; logging messages will be transmitted to the server. This can affect performance.
  14. -ensureCleanSession: If the browser does not have user profiles, make sure every new session has no artifacts from previous sessions. For example, enabling this option will cause all user cookies to be archived before launching IE, and restored after IE is closed.
  15. -trustAllSSLCertificates: Forces the Selenium proxy to trust all SSL certificates. This doesn't work in browsers that don't use the Selenium proxy.
  16. -log : writes lots of debug information out to a log file
  17. -htmlSuite : Run a single HTML Selenese (Selenium Core) suite and then exit immediately, using the specified browser (e.g. \"*firefox\") on the specified URL (e.g. \"http://www.google.com\"). You need to specify the absolute path to the HTML test suite as well as the path to the HTML results file we'll generate.
  18. -proxyInjectionMode: puts you into proxy injection mode, a mode where the selenium server acts as a proxy server for all content going to the test application. Under this mode, multiple domains can be visited, and the following additional flags are supported:
    1. -dontInjectRegex : an optional regular expression that proxy injection mode can use to know when to bypss injection
    2. -userJsInjection : specifies a JavaScript file which will then be injected into all pages
    3. -userContentTransformation : a regular expression which is matched against all test HTML content; the second is a string which will replace matches. These flags can be used any number of times. A simple example of how this could be useful: if you add \"-userContentTransformation https http" then all \"https\" strings in the HTML of the test application will be changed to be "http".
Selenium server can only have one instance running when started within the same JVM. interface with SauceLabs: http://saucelabs.com/products/docs/sauce-ondemand/basic-example-java public class sauce extends SeleneseTestCase { public void setUp() throws Exception { DefaultSelenium selenium = new DefaultSelenium( "saucelabs.com", 4444, "{\"username\": \"username-string\"," + "\"access-key\": \"access-key-string\"," + "\"os\": \"Windows 2003\"," + "\"browser\": \"firefox\"," + "\"browser-version\": \"3.\"," + "\"job-name\": \"This is an example test\"}", "http://saucelabs.com/"); selenium.start(); this.selenium = selenium; } public void testSauce() throws Exception { this.selenium.open("/"); assertEquals("Sauce Labs - Selenium-based Downloads, Hosting and Support", this.selenium.getTitle()); } }

Author:
yxl01

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.webmbt.plugin.MScriptInterface
MScriptInterface.MSCRIPT_METHOD
 
Constructor Summary
SeleniumPlugin()
           
 
Method Summary
 void click(java.lang.String locator_p)
          simulate click on the element.
 void click(java.lang.String locator_p, java.lang.String shiftCtrlAlt_p)
          simulate click on the element with option of holding down shift, ctrl or alt key.
 void click(java.lang.String locator_p, java.lang.String coordX_p, java.lang.String coordY_p)
          simulate click on the element that supports coordinates, for example an image.
 void close()
          INTERNAL USE ONLY.
 void closeWindow(java.lang.String windowName_p)
           
 boolean containsText(java.lang.String text_p)
          returns true if current page contains the text passed in.
 int count(java.lang.String locator_p)
          returns count of number of objects for the element locator passed in.
 void doubleClick(java.lang.String locator_p)
          double click on the element.
 void dragAndDrop(java.lang.String fromLocator_p, java.lang.String movement_p)
          drag and drop element by movement string.
 java.lang.String flashCall(java.lang.String flashID_p, java.lang.String funcName_p)
           
 java.lang.String flashCall(java.lang.String flashID_p, java.lang.String funcName_p, java.lang.String param1_p)
           
 java.lang.String flashCall(java.lang.String flashID_p, java.lang.String funcName_p, java.lang.String param1_p, java.lang.String param2_p)
           
 java.lang.String flashCall(java.lang.String flashID_p, java.lang.String funcName_p, java.lang.String param1_p, java.lang.String param2_p, java.lang.String param3_p)
           
 java.lang.String flashGetVariable(java.lang.String flashID_p, java.lang.String varName_p)
           
 boolean flashIsPlaying(java.lang.String flashID_p)
           
 void flashLoadMovie(java.lang.String flashID_p, java.lang.String layerNum_p, java.lang.String url_p)
           
 void flashOnProgress(java.lang.String flashID_p, java.lang.String percent_p)
           
 void flashOnReadyStateChange(java.lang.String flashID_p, java.lang.String state_p)
           
 void flashOnReadyStateChange(java.lang.String flashID_p, java.lang.String x_p, java.lang.String y_p, java.lang.String mode_p)
           
 int flashPercentLoaded(java.lang.String flashID_p)
           
 void flashPlay(java.lang.String flashID_p)
           
 void flashRewind(java.lang.String flashID_p)
           
 void flashSetVariable(java.lang.String flashID_p, java.lang.String varName_p, java.lang.String value_p)
           
 void flashSetZoonRect(java.lang.String flashID_p, java.lang.String left_p, java.lang.String top_p, java.lang.String right_p, java.lang.String bottom_p)
           
 void flashStopPlay(java.lang.String flashID_p)
           
 void flashZoom(java.lang.String flashID_p, java.lang.String percent_p)
           
 void flexAssertDisplayObject(java.lang.String locator, java.lang.String options)
           
 void flexAssertProperty(java.lang.String locator, java.lang.String options)
           
 void flexAssertText(java.lang.String locator, java.lang.String options)
           
 void flexAssertTextIn(java.lang.String locator, java.lang.String options)
           
 void flexClick(java.lang.String locator, java.lang.String flashLoc)
           
 void flexDoubleClick(java.lang.String locator, java.lang.String flashLoc)
           
 void flexDragDropElemToElem(java.lang.String locator, java.lang.String options)
           
 void flexDragDropToCoords(java.lang.String locator, java.lang.String options)
           
 void flexSelect(java.lang.String locator, java.lang.String options)
           
 void flexType(java.lang.String locator, java.lang.String options)
           
 java.lang.String getAlertText()
          returns the message in the alert popup dialog if present.
 java.lang.String[] getAllWindowsID()
           
 java.lang.String[] getAttr(java.lang.String locator_p, java.lang.String attrName_p)
          Returns the value of HTML attribute value defined in the element.
 java.lang.String getBrowserCmd(java.lang.String browserType_p, java.lang.String[] pluginParams_p)
          returns the browser startup command.
 java.lang.String getConfirmText()
          returns the message in the confirm popup dialog if present.
 java.lang.String getCookie(java.lang.String cookieName_p)
          returns the value of the cookie.
static java.lang.String getLocalSeleniumLogFileName()
          Start a selenium proxy server
 java.lang.Object getNativePluginObj()
          returns the plugin native driver object, e.g.
 java.lang.String getPluginID()
          INTERNAL USE ONLY.
 com.thoughtworks.selenium.Selenium getSession()
          returns the Selenium session used to communicate with the web application
 java.lang.String[] getText(java.lang.String locator_p)
          Returns the text of the element.
 java.lang.String getTitle()
          returns the title of the current window/page.
 java.lang.String[] getValue(java.lang.String locator_p)
          Returns the value of the element found with the locator_p.
 void init(com.webmbt.scxml.ScxmlNode scxmlNode_p, java.lang.String[] pluginParams_p)
          performs the plugin specific initialization.
 boolean isAlertPresent()
          retusn true if the alert dialog has been displayed(triggered).
 boolean isChecked(java.lang.String locator_p)
          returns true if the locator_p is checked: radio button or checkbox only.
 boolean isConfirmPresent()
          retusn true if the confirm dialog has been displayed(triggered).
 boolean isDisabled(java.lang.String locator_p)
          returns true if any of the elements found is disabled.
 boolean isError(java.lang.Exception e_p)
          INTERNAL USE ONLY.
 boolean isPresent(java.lang.String locator_p)
          returns true if the element exists in the current page/frame/window.
 boolean isVisible(java.lang.String locator_p)
          returns true if any of the elements is visible.
 java.lang.String js(java.lang.String winLocator_p, java.lang.String javascript_p)
          executes javascript passed in on the window identified in winLocator_p.
 void mouseDown(java.lang.String locator_p)
          trigger mouse down event on element locator_p
 void mouseOver(java.lang.String locator_p)
          trigger mouse over event on the element locator_p
 void mouseUp(java.lang.String locator_p)
          trigger mouse up event on the element locator_p
 void openURL(java.lang.String url_p)
          opens the url passed in and set it to be current page.
 void refresh()
          click on the browser refresh button
 void rightClick(java.lang.String locator_p)
          use contextMenu('loc')
 void selectFrame(java.lang.String frameName_p)
          select the named frame as the current default frame.
 void selectOption(java.lang.String locator_p, java.lang.String optionLocator_p)
          selects the option
 void selectWindow(java.lang.String windowName_p)
          select the named window as the current default window.
 void setBrowserCmd(java.lang.String browserCmd_p)
          changes the browser before the MBT execution is started.
 void setCheckBox(java.lang.String locator_p, java.lang.String checked_p)
          sets the checkbox
 void setRadioButton(java.lang.String locator_p, java.lang.String checked_p)
          sets the radio button
 void setupAlert()
          prepare system to handle alert popup.
 void setupConfirmResponse(java.lang.String bool_p)
          prepare system to handle the confirmation dialog with OK/Yes or Cancel/No.
static void shutdown()
           
 int sizeOf(java.lang.String locator_p)
          returns the number options in the select
 java.lang.String snapEntirePage(java.lang.String fileName_p, java.lang.String options_p)
          Capture a snapshot of the entire page of current web page
 java.lang.String snapScreen(java.lang.String fileName_p)
          INTERNAL USE ONLY.
 void start()
          INTERNAL USE ONLY.
 void type(java.lang.String locator_p, java.lang.String keyString_p)
          type the string to the element if the element is an input field.
 void type(java.lang.String locator_p, java.lang.String shiftCtrlAlt_p, java.lang.String keyString_p)
          type the string to the element with the option to have shift/control/alt key pressed.
 void typeKey(java.lang.String locator_p, java.lang.String keyString_p)
          Enters a string by pressing keys which triggers key pressed event as if user is entering the string one char at a time.
 void waitForCondition(java.lang.String script_p, java.lang.String timeout_p)
          Runs the specified JavaScript snippet repeatedly until it evaluates to "true".
 void waitForFlexReady(java.lang.String locator, java.lang.String options)
           
 java.lang.String waitForPageToLoad()
          INTERNAL USE ONLY.
 java.lang.String waitForPageToLoad(java.lang.String timeoutMillis_p)
          Waits until the page (Html dom) is fully loaded.
 void webAuth(java.lang.String authType_p, java.lang.String userID_p, java.lang.String password_p, java.lang.String waitMillis_p, java.lang.String gotoURL_p)
          performs HTTP basic authentication.
 
Methods inherited from class com.webmbt.plugin.WebPluginAncestor
convertKeyString, setInitParams
 
Methods inherited from class com.webmbt.plugin.PluginAncestor
addException, getCurScript, getData, getData, getDataMgr, getDataSetRowNum, getInitParams, getMethodList, getMScriptAPI, getMScriptMethodList, getNativeMethod, getPathVar, getScriptExecutor, getVar, initialize, isReady, next, registerVarChangeListener, replaceEscapeChar, rewind, setData, setPathVar, setReady, setVar, snapScreen, uiLocatorMap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SeleniumPlugin

public SeleniumPlugin()
Method Detail

getBrowserCmd

public java.lang.String getBrowserCmd(java.lang.String browserType_p,
                                      java.lang.String[] pluginParams_p)
returns the browser startup command. Decendant can override this with its own logic to determine the custom browser command. But it should call this to resolve the standard browser command.

Parameters:
browserType_p -
Returns:

shutdown

public static void shutdown()

close

public void close()
Description copied from class: PluginAncestor
INTERNAL USE ONLY. closes the AUT, disconnect from the external resource e.g. session to Selenium server, closing watij IE object, etc.

Specified by:
close in class PluginAncestor

init

public void init(com.webmbt.scxml.ScxmlNode scxmlNode_p,
                 java.lang.String[] pluginParams_p)
          throws java.lang.Exception
Description copied from class: PluginAncestor
performs the plugin specific initialization. Decendant must implement this method.

Throws:
java.lang.Exception

snapScreen

public java.lang.String snapScreen(java.lang.String fileName_p)
                            throws java.lang.Exception
Description copied from class: PluginAncestor
INTERNAL USE ONLY. snap the current testing app browser under testing (AUT) and save the screen in png into the file passed in.

Specified by:
snapScreen in interface MScriptMethodIntf
Specified by:
snapScreen in class PluginAncestor
Throws:
java.lang.Exception

snapEntirePage

public java.lang.String snapEntirePage(java.lang.String fileName_p,
                                       java.lang.String options_p)
                                throws java.lang.Exception
Capture a snapshot of the entire page of current web page

Parameters:
fileName_p -
options_p - background=#cccccc
Returns:
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Description copied from class: PluginAncestor
INTERNAL USE ONLY. This usually involves starting up AUT (app under testing).

Specified by:
start in class PluginAncestor
Throws:
java.lang.Exception

getSession

public com.thoughtworks.selenium.Selenium getSession()
returns the Selenium session used to communicate with the web application

Returns:
Selenium

getLocalSeleniumLogFileName

public static java.lang.String getLocalSeleniumLogFileName()
Start a selenium proxy server


getPluginID

public java.lang.String getPluginID()
Description copied from class: PluginAncestor
INTERNAL USE ONLY. Returns the unique ID assigned to the plugin. This ID is not governed, that is each plugin can make up its own plugin id and as long as no other plugins currently registered/configured has the same ID, the id is good.

Specified by:
getPluginID in class PluginAncestor
Returns:

isError

public boolean isError(java.lang.Exception e_p)
Description copied from class: PluginAncestor
INTERNAL USE ONLY. returns true if the exception passed in is an error. returns false if the exception is an application exception and thus should not stop the MBT execution.

Specified by:
isError in class PluginAncestor
Returns:

waitForPageToLoad

public java.lang.String waitForPageToLoad()
Description copied from class: PluginAncestor
INTERNAL USE ONLY. wait until the page is completely loaded.

Specified by:
waitForPageToLoad in class PluginAncestor

click

public void click(java.lang.String locator_p)
           throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
simulate click on the element.

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

Throws:
com.webmbt.MBTException

click

public void click(java.lang.String locator_p,
                  java.lang.String shiftCtrlAlt_p)
           throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
simulate click on the element with option of holding down shift, ctrl or alt key.

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

shiftCtrlAlt_p - S for shift, C for ctrl, A for alt, for example "SA" for holding down Shift and Alt key.
Throws:
com.webmbt.MBTException

click

public void click(java.lang.String locator_p,
                  java.lang.String coordX_p,
                  java.lang.String coordY_p)
           throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
simulate click on the element that 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:
com.webmbt.MBTException

closeWindow

public void closeWindow(java.lang.String windowName_p)
                 throws com.webmbt.MBTException
Throws:
com.webmbt.MBTException

setupConfirmResponse

public void setupConfirmResponse(java.lang.String bool_p)
                          throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
prepare system to handle the confirmation dialog with OK/Yes or Cancel/No. Call this function before the confirmation dialog opens up. It clears previous confirm dialog message if any. isConfirmPresent() must be called right after the action script which causes the confirm to show up. optionally you may call getConfirmText() after the isConfirmPresent() call.

Throws:
com.webmbt.MBTException

containsText

public boolean containsText(java.lang.String text_p)
                     throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
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')"/>

Throws:
com.webmbt.MBTException

count

public int count(java.lang.String locator_p)
          throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
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:
com.webmbt.MBTException

doubleClick

public void doubleClick(java.lang.String locator_p)
                 throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
double click on the element.

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

Throws:
com.webmbt.MBTException

dragAndDrop

public void dragAndDrop(java.lang.String fromLocator_p,
                        java.lang.String movement_p)
                 throws com.webmbt.MBTException
drag and drop element by movement string.

Parameters:
fromLocator_p - element locator
movement_p - format x,y in pixels.
Throws:
com.webmbt.MBTException

getAlertText

public java.lang.String getAlertText()
                              throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns the message in the alert popup dialog if present. null if not.

Returns:
Throws:
com.webmbt.MBTException

getAttr

public java.lang.String[] getAttr(java.lang.String locator_p,
                                  java.lang.String attrName_p)
                           throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
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:
com.webmbt.MBTException
See Also:
http://www.w3schools.com/tags/default.asp

getConfirmText

public java.lang.String getConfirmText()
                                throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns the message in the confirm popup dialog if present. null if not.

Returns:
Throws:
com.webmbt.MBTException

getCookie

public java.lang.String getCookie(java.lang.String cookieName_p)
Description copied from interface: MScriptMethodIntf
returns the value of the cookie.


getText

public java.lang.String[] getText(java.lang.String locator_p)
                           throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
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:
com.webmbt.MBTException

getTitle

public java.lang.String getTitle()
                          throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns the title of the current window/page.

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

Throws:
com.webmbt.MBTException

getValue

public java.lang.String[] getValue(java.lang.String locator_p)
                            throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
Returns the value of the element found with the locator_p. If multiple elements found, return a String with all values strung together separated by semicolon. 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')"/>

Returns:
Throws:
com.webmbt.MBTException

isChecked

public boolean isChecked(java.lang.String locator_p)
                  throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns true if the 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:
com.webmbt.MBTException

getAllWindowsID

public java.lang.String[] getAllWindowsID()
                                   throws com.webmbt.MBTException
Throws:
com.webmbt.MBTException

isAlertPresent

public boolean isAlertPresent()
Description copied from interface: MScriptMethodIntf
retusn true if the alert dialog has been displayed(triggered).

Returns:

isConfirmPresent

public boolean isConfirmPresent()
Description copied from interface: MScriptMethodIntf
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().

Returns:

isDisabled

public boolean isDisabled(java.lang.String locator_p)
                   throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns true if any of the elements found is disabled.

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

Throws:
com.webmbt.MBTException

isPresent

public boolean isPresent(java.lang.String locator_p)
                  throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns true if the element exists in the current page/frame/window.

Example:

<if val1="$isPresent('checkbox1')" op="eq" val2="true"/>

  <log msg="checkbox1 is present on this page">

</if>

Throws:
com.webmbt.MBTException

isVisible

public boolean isVisible(java.lang.String locator_p)
                  throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns true if any of the elements is visible.

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

Throws:
com.webmbt.MBTException

mouseDown

public void mouseDown(java.lang.String locator_p)
               throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
trigger mouse down event on element locator_p

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

Throws:
com.webmbt.MBTException

mouseOver

public void mouseOver(java.lang.String locator_p)
               throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
trigger mouse over event on the element locator_p

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

Throws:
com.webmbt.MBTException

mouseUp

public void mouseUp(java.lang.String locator_p)
             throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
trigger mouse up event on the element locator_p

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

Throws:
com.webmbt.MBTException

setupAlert

public void setupAlert()
                throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
prepare system to handle alert popup. Call this function before the alert dialog opens up. It clears previous alert message if any. isAlertPresent() must be called right after the action script which causes the alert to show up. optionally you may call getAlertText() after the isAlertPresent() call.

Throws:
com.webmbt.MBTException

refresh

public void refresh()
             throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
click on the browser refresh button

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

Throws:
com.webmbt.MBTException

rightClick

public void rightClick(java.lang.String locator_p)
                throws com.webmbt.MBTException
use contextMenu('loc')

Throws:
com.webmbt.MBTException

selectFrame

public void selectFrame(java.lang.String frameName_p)
                 throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
select the named frame as the current default frame.

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

Parameters:
frameName_p - name of the frame
Throws:
com.webmbt.MBTException

selectOption

public void selectOption(java.lang.String locator_p,
                         java.lang.String optionLocator_p)
                  throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
selects the option

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:
com.webmbt.MBTException

selectWindow

public void selectWindow(java.lang.String windowName_p)
                  throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
select the named window as the current default window.

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

Parameters:
windowName_p - name of the window
Throws:
com.webmbt.MBTException

setCheckBox

public void setCheckBox(java.lang.String locator_p,
                        java.lang.String checked_p)
                 throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
sets the checkbox

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

Parameters:
locator_p - locator to the checkbox element
checked_p - true or false
Throws:
com.webmbt.MBTException

setRadioButton

public void setRadioButton(java.lang.String locator_p,
                           java.lang.String checked_p)
                    throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
sets the radio button

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

Parameters:
locator_p - locator to the radiobutton element
checked_p - true or false
Throws:
com.webmbt.MBTException

sizeOf

public int sizeOf(java.lang.String locator_p)
           throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
returns the number options in the select

Throws:
com.webmbt.MBTException

type

public void type(java.lang.String locator_p,
                 java.lang.String keyString_p)
          throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
type the string to the element if the element is an input field.

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

Throws:
com.webmbt.MBTException

type

public void type(java.lang.String locator_p,
                 java.lang.String shiftCtrlAlt_p,
                 java.lang.String keyString_p)
          throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
type the string to the element with the option to have shift/control/alt key pressed.

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

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:
com.webmbt.MBTException

typeKey

public void typeKey(java.lang.String locator_p,
                    java.lang.String keyString_p)
             throws com.webmbt.MBTException
Enters a string by pressing keys which triggers key pressed event as if user is entering the string one char at a time.

Example: $typeKey('id=textField1', 'john')

Parameters:
locator_p -
keyString_p -
Throws:
com.webmbt.MBTException

waitForCondition

public void waitForCondition(java.lang.String script_p,
                             java.lang.String timeout_p)
Runs the specified JavaScript snippet repeatedly until it evaluates to "true". The snippet may have multiple lines, but only the result of the last line will be considered. Note that, by default, the snippet will be run in the runner's test window, not in the window of your application. To get the window of your application, you can use the JavaScript snippet selenium.browserbot.getCurrentWindow(), and then run your JavaScript in there.

Parameters:
script - - the JavaScript snippet to run
timeout - - a timeout in milliseconds, after which this command will return with an error

waitForPageToLoad

public java.lang.String waitForPageToLoad(java.lang.String timeoutMillis_p)
                                   throws com.webmbt.MBTException
Waits until the page (Html dom) is fully loaded. This does not include the dynamic content created by javascript and ajax call.

Parameters:
timeoutMillis_p - max number of milliseconds to wait until it timesout.
Throws:
com.webmbt.MBTException

flashGetVariable

public java.lang.String flashGetVariable(java.lang.String flashID_p,
                                         java.lang.String varName_p)

flashCall

public java.lang.String flashCall(java.lang.String flashID_p,
                                  java.lang.String funcName_p)

flashCall

public java.lang.String flashCall(java.lang.String flashID_p,
                                  java.lang.String funcName_p,
                                  java.lang.String param1_p)

flashCall

public java.lang.String flashCall(java.lang.String flashID_p,
                                  java.lang.String funcName_p,
                                  java.lang.String param1_p,
                                  java.lang.String param2_p)

flashCall

public java.lang.String flashCall(java.lang.String flashID_p,
                                  java.lang.String funcName_p,
                                  java.lang.String param1_p,
                                  java.lang.String param2_p,
                                  java.lang.String param3_p)

flashIsPlaying

public boolean flashIsPlaying(java.lang.String flashID_p)

flashLoadMovie

public void flashLoadMovie(java.lang.String flashID_p,
                           java.lang.String layerNum_p,
                           java.lang.String url_p)

flashOnProgress

public void flashOnProgress(java.lang.String flashID_p,
                            java.lang.String percent_p)

flashOnReadyStateChange

public void flashOnReadyStateChange(java.lang.String flashID_p,
                                    java.lang.String state_p)

flashOnReadyStateChange

public void flashOnReadyStateChange(java.lang.String flashID_p,
                                    java.lang.String x_p,
                                    java.lang.String y_p,
                                    java.lang.String mode_p)

flashPercentLoaded

public int flashPercentLoaded(java.lang.String flashID_p)

flashPlay

public void flashPlay(java.lang.String flashID_p)

flashRewind

public void flashRewind(java.lang.String flashID_p)

flashSetVariable

public void flashSetVariable(java.lang.String flashID_p,
                             java.lang.String varName_p,
                             java.lang.String value_p)

flashSetZoonRect

public void flashSetZoonRect(java.lang.String flashID_p,
                             java.lang.String left_p,
                             java.lang.String top_p,
                             java.lang.String right_p,
                             java.lang.String bottom_p)

flashStopPlay

public void flashStopPlay(java.lang.String flashID_p)

flashZoom

public void flashZoom(java.lang.String flashID_p,
                      java.lang.String percent_p)

js

public java.lang.String js(java.lang.String winLocator_p,
                           java.lang.String javascript_p)
                    throws com.webmbt.MBTException
Description copied from interface: MScriptMethodIntf
executes javascript passed in on the window identified in winLocator_p.

Parameters:
winLocator_p - locator for the window where the javascript will be executed on. win=windowName. Null or blank to run on current (top) window.

For Selenium, by default the js will be executed on the Selenium object that wraps around the user window. To execute the js on the AUT window, add prefix/qualifier window. to the js function name or js object.

Returns:
blank (Selenium) or javascrpt return (HtmlUnit).
Throws:
com.webmbt.MBTException

openURL

public void openURL(java.lang.String url_p)
             throws java.lang.Exception
Description copied from class: WebPluginAncestor
opens the url passed in and set it to be current page.

Specified by:
openURL in class WebPluginAncestor
Throws:
java.lang.Exception

setBrowserCmd

public void setBrowserCmd(java.lang.String browserCmd_p)
Description copied from class: WebPluginAncestor
changes the browser before the MBT execution is started. This command should only be called in MBT_start trigger in order to be effective. You can set the browserCmd to a value from a data set to run each virtual user with different browser.

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')')"/>

Specified by:
setBrowserCmd in class WebPluginAncestor
Parameters:
browserCmd_p - iexplore, firefox for both HtmlUnit and Selenium. For Selenium you may use additional browser ids as documented in setBrowserCmd in SeleniumPlugin class including custom browser.

getNativePluginObj

public java.lang.Object getNativePluginObj()
returns the plugin native driver object, e.g. selenium returns selenium session object. INTERNAL USE ONLY!

Overrides:
getNativePluginObj in class PluginAncestor
Returns:

waitForFlexReady

public void waitForFlexReady(java.lang.String locator,
                             java.lang.String options)

flexClick

public void flexClick(java.lang.String locator,
                      java.lang.String flashLoc)

flexDoubleClick

public void flexDoubleClick(java.lang.String locator,
                            java.lang.String flashLoc)

flexSelect

public void flexSelect(java.lang.String locator,
                       java.lang.String options)

flexType

public void flexType(java.lang.String locator,
                     java.lang.String options)

flexDragDropElemToElem

public void flexDragDropElemToElem(java.lang.String locator,
                                   java.lang.String options)

flexDragDropToCoords

public void flexDragDropToCoords(java.lang.String locator,
                                 java.lang.String options)

flexAssertDisplayObject

public void flexAssertDisplayObject(java.lang.String locator,
                                    java.lang.String options)

flexAssertText

public void flexAssertText(java.lang.String locator,
                           java.lang.String options)

flexAssertTextIn

public void flexAssertTextIn(java.lang.String locator,
                             java.lang.String options)

flexAssertProperty

public void flexAssertProperty(java.lang.String locator,
                               java.lang.String options)

webAuth

public void webAuth(java.lang.String authType_p,
                    java.lang.String userID_p,
                    java.lang.String password_p,
                    java.lang.String waitMillis_p,
                    java.lang.String gotoURL_p)
             throws java.lang.Exception
Description copied from interface: MScriptMethodIntf
performs HTTP basic authentication.

Parameters:
authType_p - "HttpBasicAuth", more authentication types may be added in the future.
userID_p - user id/name
password_p - password
waitMillis_p - number of milliseconds to wait for the authentication to execute
gotoURL_p - AUT url
Throws:
java.lang.Exception


Copyright © 2008. All Rights Reserved.