|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.webmbt.plugin.PluginAncestor
com.webmbt.plugin.WebPluginAncestor
com.webmbt.plugin.HtmlUnitPlugin
public class HtmlUnitPlugin
Requires plugin parameters (in config). Plugin for HtmlUnit.
| Nested Class Summary | |
|---|---|
class |
HtmlUnitPlugin.AlertDialogHandler
you may check the alert message displayed on the dialog window. |
class |
HtmlUnitPlugin.ConfirmDialogHandler
handles the browser Confirm Dialog. |
| Nested classes/interfaces inherited from interface com.webmbt.plugin.MScriptInterface |
|---|
MScriptInterface.MSCRIPT_METHOD |
| Constructor Summary | |
|---|---|
HtmlUnitPlugin()
|
|
| 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. |
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 toLocator_p)
drag element, move it by the movement string and then release it (drag and drop). |
java.lang.String |
getAlertText()
returns the message in the alert popup dialog if present. |
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 |
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. |
java.lang.String |
getPluginID()
INTERNAL USE ONLY. |
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)
rightClick on the element |
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 to be used for executing mbt. |
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. |
int |
sizeOf(java.lang.String locator_p)
returns the number options in the select |
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)
this method is not supported by HtmlUnit. |
java.lang.String |
waitForPageToLoad()
INTERNAL USE ONLY. |
java.lang.String |
waitForPageToLoad(java.lang.String timeoutMillis_p)
waits for the page to complete the load (just html dom). |
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, getNativePluginObj, 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 |
|---|
public HtmlUnitPlugin()
| Method Detail |
|---|
public void close()
PluginAncestor
close in class PluginAncestor
public void init(com.webmbt.scxml.ScxmlNode scxmlNode_p,
java.lang.String[] pluginParams_p)
throws java.lang.Exception
PluginAncestor
java.lang.Exception
public java.lang.String snapScreen(java.lang.String fileName_p)
throws java.lang.Exception
PluginAncestor
snapScreen in interface MScriptMethodIntfsnapScreen in class PluginAncestorjava.lang.Exception
public void start()
throws java.lang.Exception
PluginAncestor
start in class PluginAncestorjava.lang.Exceptionpublic java.lang.String getPluginID()
PluginAncestor
getPluginID in class PluginAncestorpublic boolean isError(java.lang.Exception e_p)
PluginAncestor
isError in class PluginAncestorpublic java.lang.String waitForPageToLoad()
PluginAncestor
waitForPageToLoad in class PluginAncestor
public void click(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$click('id=F1')"/>
com.webmbt.MBTException
public void click(java.lang.String locator_p,
java.lang.String shiftCtrlAlt_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <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.
com.webmbt.MBTException
public void click(java.lang.String locator_p,
java.lang.String coordX_p,
java.lang.String coordY_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <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.
com.webmbt.MBTException
public boolean containsText(java.lang.String text_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="Page contains text XXXX? $containsText('XXXX')"/>
com.webmbt.MBTException
public int count(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="$found $count('name=paymentType') payment types on the screen"/>
com.webmbt.MBTException
public void doubleClick(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$doubleClick('id=F1')"/>
com.webmbt.MBTException
public void mouseDown(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$mouseDown('id=F1')"/>
com.webmbt.MBTException
public void mouseOver(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$mouseOver('id=F1')"/>
com.webmbt.MBTException
public void mouseUp(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$mouseUp('id=F1')"/>
com.webmbt.MBTException
public void dragAndDrop(java.lang.String fromLocator_p,
java.lang.String toLocator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$dragAndDrop('id=F1','100,20')"/> to drag element F1 and drop the element at location 100px to the right and 20px down from its original location.
fromLocator_p - element locatortoLocator_p - format x,y in pixels.
com.webmbt.MBTException
public java.lang.String[] getAttr(java.lang.String locator_p,
java.lang.String attrName_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <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().
com.webmbt.MBTExceptionhttp://www.w3schools.com/tags/default.asp
public java.lang.String[] getText(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="$getText('id=rowTitle')"/>
com.webmbt.MBTException
public java.lang.String getTitle()
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="Page title is: $getTitle()"/>
com.webmbt.MBTException
public java.lang.String[] getValue(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="userid is: $getValue('userid')"/>
com.webmbt.MBTException
public boolean isChecked(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="The checkbox F1 checked? $isChecked('id=F1')"/>
locator_p - locator to the checkbox
com.webmbt.MBTException
public boolean isDisabled(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="Field F1 disabled?: $isDisabled('id=F1')."/>
com.webmbt.MBTException
public boolean isPresent(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample:
<if val1="$isPresent('checkbox1')" op="eq" val2="true"/>
<log msg="checkbox1 is present on this page">
</if>
com.webmbt.MBTException
public boolean isVisible(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <log msg="Field F1 visible?: $isVisible('id=F1')."/>
com.webmbt.MBTException
public void refresh()
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$refresh()"/>
com.webmbt.MBTException
public void rightClick(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$rightClick('id=F1')"/>
com.webmbt.MBTException
public void selectWindow(java.lang.String windowName_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$selectWindow('mainWin')"/>
windowName_p - name of the window
com.webmbt.MBTException
public void selectFrame(java.lang.String frameName_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$selectFrame('frame1')"/>
frameName_p - name of the frame
com.webmbt.MBTException
public void selectOption(java.lang.String locator_p,
java.lang.String optionLocator_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$selectOption('id=selectF1','value=2')"/>
locator_p - locator for the elementoptionLocator_p - locator for the option to be selected.
For example, label=regexp:^[Oo]ther
For example, value=other
id=option1
index=2
com.webmbt.MBTException
public void setCheckBox(java.lang.String locator_p,
java.lang.String checked_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$setCheckBox('id=F1','true')"/>
locator_p - locator to the checkbox elementchecked_p - true or false
com.webmbt.MBTException
public void setRadioButton(java.lang.String locator_p,
java.lang.String checked_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$setRadioButton('id=F1','true')"/>
locator_p - locator to the radiobutton elementchecked_p - true or false
com.webmbt.MBTException
public void type(java.lang.String locator_p,
java.lang.String keyString_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <action code="$type('id=F1','abc')"/>
com.webmbt.MBTException
public void type(java.lang.String locator_p,
java.lang.String shiftCtrlAlt_p,
java.lang.String keyString_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: <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.
com.webmbt.MBTException
public void typeKey(java.lang.String locator_p,
java.lang.String keyString_p)
throws com.webmbt.MBTException
MScriptMethodIntfExample: $typeKey('id=textField1', 'john')
com.webmbt.MBTException
public void waitForCondition(java.lang.String script_p,
java.lang.String timeout_p)
public java.lang.String waitForPageToLoad(java.lang.String timeoutMillis_p)
throws com.webmbt.MBTException
MScriptMethodIntf
com.webmbt.MBTExceptionpublic java.lang.String getCookie(java.lang.String cookieName_p)
MScriptMethodIntf
public int sizeOf(java.lang.String locator_p)
throws com.webmbt.MBTException
MScriptMethodIntf
com.webmbt.MBTException
public void setupConfirmResponse(java.lang.String bool_p)
throws com.webmbt.MBTException
MScriptMethodIntf
com.webmbt.MBTException
public void setupAlert()
throws com.webmbt.MBTException
MScriptMethodIntf
com.webmbt.MBTException
public java.lang.String getAlertText()
throws com.webmbt.MBTException
MScriptMethodIntf
com.webmbt.MBTException
public java.lang.String getConfirmText()
throws com.webmbt.MBTException
MScriptMethodIntf
com.webmbt.MBTExceptionpublic boolean isAlertPresent()
MScriptMethodIntf
public boolean isConfirmPresent()
MScriptMethodIntf
public java.lang.String js(java.lang.String winLocator_p,
java.lang.String javascript_p)
throws com.webmbt.MBTException
MScriptMethodIntf
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.
com.webmbt.MBTException
public void openURL(java.lang.String url_p)
throws java.lang.Exception
WebPluginAncestor
openURL in class WebPluginAncestorjava.lang.Exceptionpublic void setBrowserCmd(java.lang.String browserCmd_p)
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')')"/>
setBrowserCmd in class WebPluginAncestorbrowserCmd_p - iexplore_6, iexplore_7, iexplore_8, firefox_2, firefox_3
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
MScriptMethodIntf
authType_p - "HttpBasicAuth", more authentication types may be added in the future.userID_p - user id/namepassword_p - passwordwaitMillis_p - number of milliseconds to wait for the authentication to executegotoURL_p - AUT url
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||