Oracle® Functional Testing OpenScript Programmer's Reference Release 13.3.0.1 E37832-12 |
|
![]() Previous |
![]() Next |
This chapter provides a complete listing and reference for the methods in the OpenScript WebDomService Class of Web Functional Module Application Programming Interface (API).
The following section provides an alphabetical listing of the methods in the OpenScript WebDomService API.
The following table lists the WebDomService API methods in alphabetical order.
Table 22-1 List of WebDomService Methods
Method | Description |
---|---|
|
Identifies an accessibility button by its path. |
|
Identifies an accessibility checkbox by its path. |
|
Identifies an accessibility combobox by its path. |
|
Identifies an accessibility element by its recorded ID and path. |
|
Identifies an accessibility listbox by its path. |
|
Identifies an accessibility menu by its path. |
|
Identifies an accessibility radio button by its path. |
|
Identifies an accessibility text box by its path. |
|
Automatically inject Javascript into the current page. |
|
Registers a text matching (assertion) test to run every time a page is requested. |
|
Registers a text matching (verification) test to run every time a page is requested. |
|
Identifies an alert dialog box by its recorded ID and path. |
|
Checks for exceptions. |
|
Searches the HTML contents of all documents in all browser windows for the specified text pattern, reporting a failure if the test fails. |
|
Constructs the property data of a single object attribute. |
|
Constructs the object attributes. |
|
Identifies a button by its recorded ID and path. |
|
Constructs the test data of a table cell. |
|
Constructs the list of table cell tests. |
|
Identifies a checkbox by its recorded ID and path. |
|
Clears all cache files. |
|
Clears all persistent Cookies. |
|
Clears cache files by defined domain name. |
|
Clears persistent Cookies by defined domain name. |
|
Clears session cookies in the current opened browser window. |
|
Identifies a confirmation dialog box by its recorded ID and path. |
|
Identifies a custom DOM element by its recorded ID and path. |
|
Identifies a dialog box by its path. |
|
Identifies a window by its recorded ID and path. |
|
Identifies an element by its recorded ID and path. |
|
Stop capturing HAR files (HTTP Archive format) for http requests. |
|
Checks if an object exists or not with a specified timeout value. |
|
Finds an element by class name in all windows and documents. |
|
Finds a list of elements by class name in all windows and documents. |
|
Finds an element by CSS selector in all windows and documents. |
|
Finds a list of elements by CSS selector in all windows and documents. |
|
Finds an element by id in all windows and documents. |
|
Finds an element by name in all windows and documents. |
|
Finds a list of elements by name in all windows and documents. |
|
Finds an element by tag name in all windows and documents.. |
|
Finds a list of elements by tag name in all windows and documents. |
|
Finds an element by W3C XPath in all windows and documents. |
|
Find a list of elements by W3C XPath in all windows and documents. |
|
Gets the window with the focus. |
|
Gets the WebDomEventService so that the user can add or remove event listeners. |
|
Identifies an image by its recorded ID and path. |
|
Identifies a link by its recorded ID and path. |
|
Identifies a login dialog box by its recorded ID and path. |
|
Identifies a notification bar by its path. |
|
Identifies an object by its recorded ID and path. |
|
Identifies a prompt dialog box by its recorded ID and path. |
|
Identifies a radio button by its recorded ID and path. |
|
Removes a global text matching test (either assertion or verification). |
|
Identifies a select list box by its recorded ID and path. |
|
Searches the HTML contents of all documents in all browsers for the specified regular expression pattern. |
|
Start to capture HAR files (HTTP Archive format) for http requests. |
|
Identifies a table by its recorded ID and path. |
|
Identifies a text area by its recorded ID and path. |
|
Identifies a text box by its recorded ID and path. |
|
Perform the web accessibility testing to the active window and generate the report to results folder. |
|
Searches the HTML contents of all documents in all browser windows for the specified text pattern, reporting a warning if the test fails. |
|
Waits for an object to exist before timing out. |
|
Identifies a window by its recorded ID and path. |
|
Identifies an xml document by its recorded ID and path. |
The following sections provide detailed reference information for each method and enum in the WebDomService Class of Web Functional Module Application Programming Interface.
Identifies an accessibility button by its path.
Format
The web.accButton method has the following command format(s):
web.accButton(path);
web.accButton(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on a button specified by its path.
//using script variable getVariables().set("btnPath", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accPushButton[@index='1']"); web.accButton(1, "{{btnPath}}").click(); //using Java variable String btnPath = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accPushButton[@index='1']"; web.accButton(10, btnPath).click();
Identifies an accessibility checkbox by its path.
Format
The web.accCheckBox method has the following command format(s):
web.accCheckBox(path);
web.accCheckBox(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on a checkbox specified by its recorded ID and path.
//using script variable getVariables().set("cbpath", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accCheckButton[@index='0']"); web.accCheckBox(1, "{{cbpath}}").check(true); //using Java variable String cbpath = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accCheckButton[@index='0']"; web.accCheckBox(2, cbpath).check(false);
Identifies an accessibility combobox by its path.
Format
The web.accComboBox method has the following command format(s):
web.accComboBox(path);
web.accComboBox(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on the combobox specified by its recorded ID and path.
//using script variable getVariables().set("combobox", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accComboBox[@index='0']"); web.accComboBox(101, "{{combobox}}").selectOptionByText("Bikes"); //using Java variable String combobox = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accComboBox[@index='0']"; web.accComboBox((101, combobox).selectOptionByIndex(0);
Identifies an accessibility element by its recorded ID and path.
Format
The web.accElement method has the following command format(s):
web.accElement(path);
web.accElement(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on an accessibility element specified by its recorded ID and path.
//using script variable getVariables().set("elmPath", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='3']" + "/web:accClient[@index='0']"); web.accElement(56, "{{elmPath}}").mouseClick(260, 265); //using Java variable String elmPath = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='3']" + "/web:accClient[@index='0']"; web.accElement(56, elmPath).mouseClick(260, 265);
Identifies an accessibility listbox by its path.
Format
The web.accListBox method has the following command format(s):
web.accListBox(path);
web.accListBox(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on the list box specified by its recorded ID and path.
//using script variable getVariables().set("listbox", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accList[@index='0']"); web.accListBox(101, "{{listbox}}").selectOptionByText("Bikes"); //using Java variable String listbox = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accList[@index='0']"; web.accListBox(101, listbox).selectOptionByIndex(0);
Identifies an accessibility menu by its path.
Format
The web.accMenu method has the following command format(s):
web.accMenu(path);
web.accMenu(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on an accessibility menu specified by its recorded ID and path.
//using script variable getVariables().set("menu", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accMenu[@index='0']"); web.accMenu(101, "{{menu}}").selectNode("File->Open"); //using Java variable String menu = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accMenu[@index='0']"; web.accMenu(101, menu).selectNode("File->Open");
Identifies an accessibility radio button by its path.
Format
The web.accRadioButton method has the following command format(s):
web.accRadioButton(path);
web.accRadioButton(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on a radio button specified by its recorded ID and path.
//using script variable getVariables().set("radioBtn", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accRadioButton[@index='0' " + "or @name='Search Any']"); web.accRadioButton(96, "{{radioBtn}}").select(); //using Java variable String radioBtn = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accRadioButton[@index='0' " + "or @name='Search Any']"; web.accRadioButton(96, radioBtn).select();
Identifies an accessibility text box by its path.
Format
The web.accTextBox method has the following command format(s):
web.accTextBox(path);
web.accTextBox(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Clicks on a text box specified by its recorded ID and path and sets the text in the text box.
//using script variable getVariables().set("tbPath", "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accText[@index='0']"); web.accTextBox(10, "{{tbPath}}").setText("text box text"); //using Java variable String tbPath = "/web:window[@index='0']" + "/web:document[@index='0']" + "/web:object[@index='0']" + "/web:accText[@index='1']"; web.accTextBox(10, tbPath).setText("text box text");
Automatically inject Javascript into the current page.
This method must be called before the browser launch.
Format
The web.addAutoInjectionScripts method has the following command format(s):
web.addAutoInjectionScripts(scriptFiles);
Example
Set Javascript files that need to be auto-injected, then execute the injected javascript function..
List<File> lists = new ArrayList<File>();
lists.add(new File("C:\\myScripts\\script1.js"));
lists.add(new File("C:\\myScripts\\script2.js"));
lists.add(new File("C:\\myScripts\\script3.js"));
web.addAutoInjectionScripts(lists);
browser.launch();
[...]
web.window(2,"/web:window[@index='0' or @title='about:blank']")
.navigate("http://example.com/default.htm");
web.window(4,"/web:window[@index='0' or @title='Web Events']")
.waitForPage(null);
{
think(5.543);
}
info(web.document("/web:window[@index='0']/web:document[@index='0']")
.executeJsFunction("injectedFunc1")[0]);
Registers a text matching (assertion) test to run every time a page is requested.
The text matching (assertion) test searches the HTML contents of all documents in all browser windows for the specified text pattern. If the test fails, the script will always fail and stop running, unless the text matching test error recovery setting specifies a different action such as Warn or Ignore.
The assertion is performed for all requests made by this virtual user.
This method supports result code verification methods including getLastResult()
and getLastError()
.
To unregister a global text assertion, use web.removeGlobalTextValidator.
Format
The web.addGlobalAssertText method has the following command format(s):
web.addGlobalAssertText(testName, textToAssert, sourceType, textPresence, matchOption);
Command Parameters
A string specifying a descriptive name of the test being applied. This name may be used by a subsequent call to web.removeGlobalTextValidator. Must not be null
.
a String specifying the text to match on the page, or not match on the page if TextPresence is TextPresence.PassIfPresent. Must not be null
.
a Source enum specifying the location to match the text either in the HTML contents or HTTP response headers. Must not be null.
TextPresence enum specifying Either PassIfPresent or FailIfPresent, depending on if you want the text to be present or not.
a MatchOption enum specifying either Exact, RegEx, or Wildcard, depending on match type.
Example
Adds a Global Text Matching test for Display Content, Response Header, and Source HTML respectively.
globalTextMatchingTest1
passes if the text to match string is present in the Display Content and matches exactly.
globalTextMatchingTest2
passes if the text to match string is present in the Response header and matches the Regular Expression.
globalTextMatchingTest3
fails if the text to match string is present in the Source HTML and matches the Wildcard.
web.addGlobalAssertText("globalTextMatchingTest1", "match this text string", Source.DisplayContent, TextPresence.PassIfPresent, MatchOption.Exact); web.addGlobalAssertText("globalTextMatchingTest2", "jsessionid=(.+?)(?:\\\"|&)", Source.ResponseHeader, TextPresence.PassIfPresent, MatchOption.RegEx); web.addGlobalAssertText("globalTextMatchingTest3", "match this *", Source.Html, TextPresence.FailIfPresent, MatchOption.Wildcard);
Registers a text matching (verification) test to run every time a page is requested.
The text matching (verification) test searches the HTML contents of all documents in all browser windows for the specified text pattern. If the test fails, a warning is always reported, irrespective of current Error Recovery settings.
The verification is performed for all requests made by this virtual user.
This method supports result code verification methods including getLastResult()
and getLastError()
.
To unregister a global text verification, use web.removeGlobalTextValidator.
Format
The web.addGlobalVerifyText method has the following command format(s):
web.addGlobalVerifyText(testName, textToAssert, sourceType, textPresence, matchOption);
Command Parameters
a String specifying the descriptive name of the test being applied. This name may be used by a subsequent call to web.removeGlobalTextValidator. Must not be null.
a String specifying the text to match on the page, or not match on the page if TextPresence says TextPresence.PassIfPresent. Must not be null.
a Source enum specifying where to match the text either in the HTML contents or HTTP response headers. Must not be null.
a TextPresence enum specifying either PassIfPresent or FailIfPresent, depending on if you want the text to be present or not.
a MatchOption enum specifying either Exact, RegEx, or Wildcard, depending on match type.
Example
Adds a Global Text Matching test for Display Content, Response Header, and Source HTML respectively.
globalTextMatchingTest1
passes if the text to match string is present in the Display Content and matches exactly.
globalTextMatchingTest2
passes if the text to match string is present in the Response header and matches the Regular Expression.
globalTextMatchingTest3
fails if the text to match string is present in the Source HTML and matches the Wildcard.
web.addGlobalVerifyText("globalTextMatchingTest1", "match this text string", Source.DisplayContent, TextPresence.PassIfPresent, MatchOption.Exact); web.addGlobalVerifyText("globalTextMatchingTest2", "jsessionid=(.+?)(?:\\\"|&)", Source.ResponseHeader, TextPresence.PassIfPresent, MatchOption.RegEx); web.addGlobalVerifyText("globalTextMatchingTest3", "match this *", Source.Html, TextPresence.FailIfPresent, MatchOption.Wildcard);
Identifies an alert dialog box by its recorded ID and path.
Format
The web.alertDialog method has the following command format(s):
web.alertDialog(path);
web.alertDialog(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on an alert dialog box specified by its recorded ID and path.
//using script variable getVariables().set("dlgPath", "/web:dialog_alert[@text='ALERT!' and @index='0']"); web.alertDialog(1, "{{dlgPath}}").clickOk(); //using Java variable String dlgPath = "/web:dialog_alert[@text='ALERT!' and @index='0']"; web.alertDialog(42, dlgPath).clickOk();
Checks for exceptions. Manually enter this method into a script to check if an exception occurred.
If there are exception in previous stepResult, just break the script.
Searches the HTML contents of all documents in all browser windows for the specified text pattern, reporting a failure if the test fails.
If the test fails, always fail the script unless the text matching test error recovery setting specifies a different action such as Warn or Ignore.
Format
The web.assertText method has the following command format(s):
web.assertText(testName, pattern, sourceType, textPresence, matchOption);
Command Parameters
a String specifying the test name.
a String specifying the pattern of the test.
a Source enum specifying the location to match, either the source HTML or the HTML excluding markup tags.
a TextPresence enum specifying either PassIfPresent or FailIfPresent, depending on if you want the text to be present or not.
a MatchOption enum specifying either Exact, RegEx, or Wildcard, depending on match type.
Throws
if the assertion fails. AbstractScriptException on any other failure when attempting to assert the text.
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Adds Text Matching tests for Display Content and Raw HTML.
myTextMatchingTest1
passes if the text to match string is present in the Display Content and matches exactly.
myTextMatchingTest2
passes if the text to match string is present in the source HTML and matches the Regular Expression.
myTextMatchingTest3
fails if the text to match string is present in the source HTML and matches the Wildcard.
web.assertText("myTextMatchingTest1", "match this text string", Source.DisplayContent, TextPresence.PassIfPresent, MatchOption.Exact); web.assertText("myTextMatchingTest2", "match(.+?)(?:\"|&)", Source.Html, TextPresence.PassIfPresent, MatchOption.RegEx); web.assertText("myTextMatchingTest3", "match this *", Source.Html, TextPresence.FailIfPresent, MatchOption.Wildcard);
Constructs the property data of a single object attribute.
Format
The web.attribute method has the following command format(s):
web.attribute(property, expectedValue, operator);
Command Parameters
a String specifying the name of the property.
a String specifying the expected value of the property.
TestOperator that defines the type and the match approach of the data.
Example
Specifies each individual attribute of an Object Test.
getVariables().set("elmPath", "/web:window[@index='0' or @title='Mockups']" + "/web:document[@index='0']" + "/web:table[@id='toc' or @index='0']"); web.element(122,"{{elmPath}}").assertAttributes("MyObjectTest", web.attributes(web.attribute("tag", "TABLE", TestOperator.StringExact), web.attribute("id", "toc", TestOperator.StringExact), web.attribute("className", "toc", TestOperator.StringExact), web.attribute("class", "toc", TestOperator.StringExact), web.attribute("summary", "Conts", TestOperator.StringExact), web.attribute("index", "0", TestOperator.StringExact)));
Constructs the object attributes.
Example
Specifies the attibutes of an Object Test.
getVariables().set("elmPath", "/web:window[@index='0' or @title='Mockups']" +
"/web:document[@index='0']" +
"/web:table[@id='toc' or @index='0']");
web.element(122,"{{elmPath}}").assertAttributes("MyObjectTest",
web.attributes(web.attribute("tag", "TABLE", TestOperator.StringExact),
web.attribute("id", "toc", TestOperator.StringExact),
web.attribute("className", "toc", TestOperator.StringExact),
web.attribute("class", "toc", TestOperator.StringExact),
web.attribute("summary", "Contents", TestOperator.StringExact),
web.attribute("index", "0", TestOperator.StringExact)));
Identifies a button by its recorded ID and path.
Format
The web.button method has the following command format(s):
web.button(path);
web.button(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on a button specified by its recorded ID and path.
//using script variable getVariables().set("btnPath", "/web:window[@index='0' " + "or @title='Stocks']" + "/web:document[@index='0']" + "/web:form[@id='loginform' or @name='loginform' " + "or @index='0']" + "/web:input_submit[@name='LoginButton' or @value='Login' " + "or @index='0']"); web.button(1, "{{btnPath}}").click(); web.button(2, "{{btnPath}}").mouseClick("<CTRL>", 1, false); //using Java variable String btnPath = "/web:window[@index='0' or @title='Stocks']" + "/web:document[@index='0'] " + "/web:form[@id='loginform' or @name='loginform' " + "or @index='0']" + "/web:input_submit[@name='LoginButton' or @value='Login' " + "or @index='0']"; web.button(1, btnPath).click(); web.button(2, btnPath).mouseClick("<CTRL>", 1, false);
Constructs the test data of a table cell.
Format
The web.cell method has the following command format(s):
web.cell(row, column, expectedValue, operator);
Command Parameters
a 1-based index value specifying the row number.
a 1-based index value specifying the column number.
a String specifying the expected value of the property.
a TestOperator enum that defines the type and the match approach of the data.
Example
Adds a table test for specifying exact match or wildcard match for individual cells.
web.table(14,"/web:window[@title='Ticker List']" + "/web:document[@index='0']" + "/web:table[@index='6']") .assertCells("MyTableTest", web.cells(web.cell(1, 1, "Ticker ",TestOperator.StringExact), web.cell(1, 2,"Company ", TestOperator.StringExact), web.cell(2, 1, "ORCL*", TestOperator.StringWildCard), web.cell(2, 2, "Oracle", TestOperator.StringExact)));
Constructs the list of table cell tests.
Example
Adds a table test for specifying exact match or wildcard match for each cell.
web.table(14,"/web:window[@title='Ticker List']" +
"/web:document[@index='0']" +
"/web:table[@index='6']")
.assertCells("MyTableTest",
web.cells(web.cell(1, 1, "Ticker ",TestOperator.StringExact),
web.cell(1, 2,"Company ", TestOperator.StringExact),
web.cell(2, 1, "ORCL*", TestOperator.StringWildCard),
web.cell(2, 2, "Oracle", TestOperator.StringExact)));
Identifies a checkbox by its recorded ID and path.
Format
The web.checkBox method has the following command format(s):
web.checkBox(path);
web.checkBox(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on a checkbox specified by its recorded ID and path.
//using script variable getVariables().set("cbpath", "/web:window[@index='0' " + "or @title='Chart Portfolio']" + "/web:document[@index='0']" + "/web:input_checkbox[@id='chkTrack' or @name='chkTrack' " + "or @index='0']"); web.checkBox(1, "{{cbpath}}").click(); web.checkBox(2, "{{cbpath}}").check(true); web.checkBox(3, "{{cbpath}}").dblClick(); web.checkBox(4, "{{cbpath}}").mouseClick(1, 1, "<ALT>", 1, false, ClickPosition.Center); web.checkBox(5, "{{cbpath}}").clickContextMenu("contextMenuItem", 0); web.checkBox(6, "{{cbpath}}").keyPress("<SPACE>"); //using Java variable String cbpath = "/web:window[@index='0' " + "or @title='Chart Portfolio']" + "/web:document[@index='0']" + "/web:input_checkbox[@id='chkTrack' or @name='chkTrack' " + "or @index='0']"; web.checkBox(1, cbpath).click(); web.checkBox(2, cbpath).check(true); web.checkBox(3, cbpath).dblClick(); web.checkBox(4, cbpath).mouseClick(1, 1, "<ALT>", 1, false, ClickPosition.Center); web.checkBox(5, cbpath).clickContextMenu("contextMenuItem", 0); web.checkBox(6, cbpath).keyPress("<SPACE>");
Clears all persistent Cookies.
Format
The web.clearAllPersistentCookies method has the following command format(s):
web.clearAllPersistentCookies( );
Clears persistent Cookies by defined domain name.
Format
The web.clearPersistentCookies method has the following command format(s):
web.clearPersistentCookies(domainName);
Clears session cookies in the current opened browser window.
Format
The web.clearSessionCookies method has the following command format(s):
web.clearSessionCookies( );
Identifies a confirmation dialog box by its recorded ID and path.
Format
The web.confirmDialog method has the following command format(s):
web.confirmDialog(path);
web.confirmDialog(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on a open JavaScript dialog box specified by its recorded ID and path.
//using script variable getVariables().set("cfmDialog", "/web:dialog_confirm[@text='Continue? OK/Cancel' " + "and @index='0']"); web.confirmDialog(46, "{{cfmDialog}}").clickOk(); //using Java variable String cfmDialog = "/web:dialog_confirm[@text='Continue? OK/Cancel' " + "and @index='0']"; web.confirmDialog(46, cfmDialog).clickCancel();
Identifies a custom DOM element by its recorded ID and path.
Format
The web.customElement method has the following command format(s):
web.customElement(path);
web.customElement(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on the custom element specified by its path.
getVariables().set("custElmPath", "/web:window[@index='0' " +
"or @title='Mail Order']" +
"/web:document[@index='0']" +
"/web:web:element[@id='btnBikes' or @name='btnBikes' " +
"or @index='0']");
web.customElement(12, "{{custElmPath}}").assertAttribute("myTest", "id",
"btnBikes", TestOperator.StringExact);
Identifies a dialog box by its path.
Format
The web.dialog method has the following command format(s):
web.dialog(path);
web.dialog(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on an open dialog box specified by its recorded ID and path.
//using script variable getVariables().set("dlgPath", "/web:dialog_unknown[@text='an input box' and @index='0']"); web.dialog(1, "{{dlgPath}}").setText(0, "text input"); web.dialog(2, "{{dlgPath}}").clickButton(0); //using Java variable String dlgPath = "/web:dialog_unknown[@text='an input box' and @index='0']"; web.dialog(1, dlgPath).setText(0, "text input"); web.dialog(2, dlgPath).clickButton(0);
Identifies a window by its recorded ID and path.
Format
The web.document method has the following command format(s):
web.document(path);
web.document(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on an open web document specified by its recorded ID and path.
getVariables().set("recHtml", web.document(1, "/web:document[@index='0]'").getHTML()); info("The HTML string is: {{recHtml}}"); getVariables().set("recUrl", web.document(2, "/web:document[@index='0]'").getRecordedURL()); info("The URL is: {{recUrl}}");
Identifies an element by its recorded ID and path.
Format
The web.element method has the following command format(s):
web.element(path);
web.element(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on an open VB Script dialog box specified by its recorded ID and path.
//using script variable getVariables().set("elmPath", "/web:window[@index='1' " + "or @title='VBScript Form']" + "/web:document[@index='0']" + "/web:table[@index='0']"); web.element(56, "{{elmPath}}").click(); //using Java variable String elmPath1 = "/web:window[@index='1' " + "or @title='VBScript Form']" + "/web:document[@index='0']" + "/web:table[@index='0']"; web.element(56, elmPath).click();
Stop capturing HAR files (HTTP Archive format) for http requests.
This API currently only works on Chrome. Use web.startCaptureHARs(harPath) to start the capture. This API must be used before the browser closes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Stop capturing HAR files (HTTP Archive format) for http requests.
public void initialize() throws Exception {
browser.launch();
web.startCaptureHARs("C:\\OracleATS\\logs\\HAR",example_jet_cookbook);
}
public void run() throws Exception {
[...]
web.window(2, "/web:window[@index='0' or @title='www.example.com/Cookbook.html")
.navigate("http://www.example.com/Cookbook.html");
[...]
}
public void finish() throws Exception {
web.endCaptureHARs();
browser.close();
}
Checks if an object exists or not with a specified timeout value.
Format
The web.exists method has the following command format(s):
web.exists(path);
web.exists(path, timeout);
Finds an element by class name in all windows and documents. If multiple elements are found, return the first one.
Format
The web.findElementByClassName method has the following command format(s):
web.findElementByClassName(className);
Finds a list of elements by class name in all windows and documents.
Format
The web.findElementsByClassName method has the following command format(s):
web.findElementsByClassName(className);
Finds an element by CSS selector in all windows and documents. If multiple elements are found, return the first one.
Format
The web.findElementByCssSelector method has the following command format(s):
web.findElementByCssSelector(cssSelector);
Finds a list of elements by CSS selector in all windows and documents.
Format
The web.findElementsByCssSelector method has the following command format(s):
web.findElementsByCssSelector(cssSelector);
Finds an element by name in all windows and documents. If multiple elements are found, return the first one.
Format
The web.findElementByName method has the following command format(s):
web.findElementByName(name);
Finds a list of elements by name in all windows and documents.
Format
The web.findElementsByName method has the following command format(s):
web.findElementsByName(name);
Finds an element by tag name in all windows and documents.
Format
The web.findElementByTagName method has the following command format(s):
web.findElementByTagName(tagName);
Finds a list of elements by tag name in all windows and documents.
Format
The web.findElementsByTagName method has the following command format(s):
web.findElementsByTagName(tagName);
Finds an element by W3C XPath in all windows and documents. This API currently only works on Firefox, Chrome and Edge.
Format
The web.findElementByXPath method has the following command format(s):
web.findElementByXPath(W3CXPath);
Finds a list of elements by W3C XPath in all windows and documents. This API currently only works on Firefox, Chrome and Edge.
Format
The web.findElementsByXPath method has the following command format(s):
web.findElementsByXPath(W3CXPath);
Gets the window with the focus.
Format
The web.getFocusedWindow method has the following command format(s):
web.getFocusedWindow( );
Gets the WebDomEventService so that the user can add or remove event listeners.
Format
The web.getWebDomEventService method has the following command format(s):
web.getWebDomEventService( );
Example
The following examples the listener would be called twice. First, it would be called before finding the web.textBox(9,"/web:window[@index='0']/web:document [@index='0']/web:form[@id='loginform']/web:input_text[@id='login']") element. Second, it would be called before finding element by css selector, namely web.findElementByCssSelector("input").
web.getWebDomEventService().addBeforeFindElementListener
(new IWebDomEventListener(){
{@literal @Override}
public void onEvent() {
System.out.println("BeforeFindElementListener enter");
[...]
System.out.println("BeforeFindElementListener exit");
}
});
web.window(6, "/web:window[@index='0']").navigate("example.com/default.htm");
web.window(8, "/web:window[@index='0']").waitForPage(null);
web.textBox(9,"/web:window[@index='0']" +
"/web:document[@index='0']" +
"/web:form[@id='loginform']" +
"/web:input_text[@id='login']")
.click();
DOMElement input = web.findElementByCssSelector("input");
input.click();
Identifies an image by its recorded ID and path.
Format
The web.image method has the following command format(s):
web.image(path);
web.image(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on an image specified by its recorded ID and path.
//using script variable getVariables().set("imgPath", "/web:window[@index='0' " + "or @title='Mail Order']" + "/web:document[@index='0']" + "/web:input_image[@id='btnBikes' or @name='btnBikes' " + "or @src='http://testserver2/images/bikes.jpg' " + "or @index='0']"); web.image(82, "{{imgPath}}").click(); //using Java variable String imgPath = "/web:window[@index='0' or @title='Mail Order']" + "/web:document[@index='0']" + "/web:input_image[@id='btnBikes' or @name='btnBikes' " + "or @src='http://testserver2/images/bikes.jpg' " + "or @index='0']"; web.image(82, imgPath).click();
Identifies a link by its recorded ID and path.
Format
The web.link method has the following command format(s):
web.link(path);
web.link(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on the link specified by its recorded ID and path.
//using script variable getVariables().set("lnkPath", "/web:window[@index='0' " + "or @title=' Bikes']" + "/web:document[@index='0']" + "/web:a[@text='Mail Order Bikes' " + "or @href='http://testserver2/bikes/Main.aspx' " + "or @index='5']"); web.link(60, "{{lnkPath}}").click(); //using Java variable String lnkPath = "/web:window[@index='0' or @title=' Bikes']" + "/web:document[@index='0']" + "/web:a[@text='Mail Order Bikes' " + "or @href='http://testserver2/bikes/Main.aspx' " + "or @index='5']"; web.link(60, lnkPath).click();
Identifies a login dialog box by its recorded ID and path.
Format
The web.loginDialog method has the following command format(s):
web.loginDialog(path);
web.loginDialog(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on the login dialog box specified by its recorded ID and path.
getVariables().set("dlgPath", "/web:dialog_unknown[@text='Login!' " + "and @index='0']"); //Click OK with username and password. Remember password true. web.loginDialog(10, "{{dlgPath}}").clickOk("username", decrypt("vGXUWvDW/F7E6OSYUjRmsQ=="), true); //Click Cancel web.loginDialog(15, "{{dlgPath}}").clickCancel();
Identifies a notification bar by its path.
Format
The web.notificationBar method has the following command format(s):
web.notificationBar(path);
web.notificationBar(recId, path);
Command Parameters
the ID of a previously recorded navigation, used for comparison purposes.
a String specifying the object path.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on a notification bar specified by its recorded ID and path.
//using script variable getVariables().set("notiBarPath", "/web:window[@index='0' or @title='Download Portfolio']"); web.notificationBar("{{notiBarPath}}").selectOptionBy(3, 1); web.notificationBar("{{notiBarPath}}").clickButton(2); //using Java variable String notiBarPath = "/web:window[@index='0' or @title='Download Portfolio']"; web.notificationBar(notiBarPath).selectOptionBy(3, 1); web.notificationBar(notiBarPath).clickButton(2);
fies an object by its recorded ID an
Format
The web.object method has the following command format(s):
web.object(path);
web.object(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Identifies a prompt dialog box by its recorded ID and path.
Format
The web.promptDialog method has the following command format(s):
web.promptDialog(path);
web.promptDialog(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on the prompt dialog box specified by its recorded ID and path.
//using script variable getVariables().set("dlgPropmt", "/web:dialog_prompt[@text='Script Prompt:' " + "and @index='0']"); web.promptDialog(90, "{{dlgPropmt}}").clickOk("input text"); //using Java variable String dlgPropmt = "/web:dialog_prompt[@text='Script Prompt:' and @index='0']"; web.promptDialog(90, dlgPropmt).clickOk("input text");
Identifies a radio button by its recorded ID and path.
Format
The web.radioButton method has the following command format(s):
web.radioButton(path);
web.radioButton(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on a radio button specified by its recorded ID and path.
//using script variable getVariables().set("radioBtn", "/web:window[@index='0' or @title='Sell']" + "/web:document[@index='0']" + "/web:form[@index='0']" + "/web:input_radio[@id='symbol3' " + "or (@name='symbol' and @value='ORCL') or @index='2']"); Boolean isSelected = web.radioButton(96, "{{radioBtn}}") .isSelected(); if (isSelected = false) { info("radio button not selected"); web.radioButton(96, "{{radioBtn}}").select(); } //using Java variable String radioBtn = "/web:window[@index='0' or @title='Sell']" + "/web:document[@index='0']/web:form[@index='0']" + "/web:input_radio[@id='symbol3'" + "or (@name='symbol' and @value='ORCL') or @index='2']"); Boolean isSelected = web.radioButton(96, "{{radioBtn}}") .isSelected(); if (isSelected = false) { info("radio button not selected"); web.radioButton(96, radioBtn).select(); }
Removes a global text matching test (either assertion or verification).
This method removes text matching tests that were previously added using web.addGlobalAssertText or web.addGlobalVerifyText.
If the specified test was not previously added, this method does nothing. No error is thrown.
Format
The web.removeGlobalTextValidator method has the following command format(s):
web.removeGlobalTextValidator(testName);
Command Parameters
a String specifying the name of the test previously addedusing web.addGlobalAssertTextor web.addGlobalVerifyText.
Identifies a select list box by its recorded ID and path.
Format
The web.selectBox method has the following command format(s):
web.selectBox(path);
web.selectBox(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Examples of actions on the select list box specified by its recorded ID and path.
//using script variable getVariables().set("selectList", "/web:window[@index='0'" + "or @title='downhill bikes home']" + "/web:document[@index='0']" + "/web:form[@id='Default' or @name='Default' or @index='0']" + "/web:select[(@id='lstCatalogCategory' or @name='lstCatalogCategory'" + ""or @index='0') and multiple mod 'False']"); web.selectBox(1, "{{selectList}}").selectOptionByText("Bikes"); //using Java variable String selectList = "/web:window[@index='0'r @title='downhill bikes home']" + "/web:document[@index='0']" + "/web:form[@id='Default' or @name='Default' or @index='0']" + "/web:select[(@id='lstCatalogCategory' or @name='lstCatalogCategory'" + "or @index='0') and multiple mod 'False']"; web.selectBox(1, selectList).selectOptionByText("Bikes"); //multiple list select using script variable getVariables().set("selectList", "/web:window[@index='0' " + "or @title='downhill bikes home']" + "/web:document[@index='0']" + "/web:form[@id='Default' or @name='Default' or @index='0']" + "/web:select[(@id='lstCatalogCategory' or @name='lstCatalogCategory'" + "or @index='0') and multiple mod 'True']"); web.selectBox(1, "{{selectList}}").multiSelectOptionByText("Bikes", "Parts");
Searches the HTML contents of all documents in all browsers for the specified regular expression pattern.
Found results are stored in the variable named varName
. If no results are found, and error recovery settings specify that WEBDOM_SOLVE_ERROR should fail, then this method throws a SolveException
.
Format
The web.solve method has the following command format(s):
web.solve(varName, pattern, sourceType, resultIndex);
Command Parameters
a String specifying the name of the variable to create.
a String specifying the Regular Expression pattern specifying what to extract from each document's HTML contents.
a Source emun specifying the location to match, either the raw HTML or the HTML excluding markup tags.
a value specifying which value to match if the pattern matches more than 1 value. Specify the 0-based index of the specific result to retrieve. If null
is specified, all results will be added into the variables collection.For example, the first result found is stored in varName
,the second is stored in varName[1]
, the third in varName[2]
, [...]
Throws
If no results are found, and error recovery settings specifythat WEBDOM_SOLVE_ERROR should fail, then this method throws a SolveException
.
Example
Parse a value from the most recent navigation's specified source using a Regular Expression and store it in a variable. Includes a result index value of 0 to specify it should retrieve the first match result.
web.solve("varTitle", "<TITLE>(.+)</TITLE>", Source.Html, 0);
info("Page Title = {{varTitle}}");
Start to capture HAR files (HTTP Archive format) for http requests.
This API currently only works on Chrome. Use web.endCaptureHARs() to stop the capture. This API must be used after the browser launches.
Format
The web.startCaptureHARs method has the following command format(s):
web.startCaptureHARs(harPath);
web.startCaptureHARs(harPath, fileName);
Command Parameters
a String specifying the name of the variable to create.
a String specifying the name of the HAR file. The HAR file will be named with fileName_time.har.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Capture HAR files for http requests.
public void initialize() throws Exception {
browser.launch();
web.startCaptureHARs("C:\\OracleATS\\logs\\HAR",example_jet_cookbook);
}
public void run() throws Exception {
[...]
web.window(2, "/web:window[@index='0' or @title='www.example.com/Cookbook.html")
.navigate("http://www.example.com/Cookbook.html");
[...]
}
public void finish() throws Exception {
web.endCaptureHARs();
browser.close();
}
Identifies a table by its recorded ID and path.
Format
The web.table method has the following command format(s):
web.table(path);
web.table(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on the table specified by its recorded ID and path.
getVariables().set("tblPath", "/web:window[@index='0' " +
"or @title='Ticker List']" +
"/web:document[@index='0']" +
"/web:table[@index='6']");
web.table(14, "{{tblPath}}").assertCells("MyTableTest",
web.cells(web.cell(1, 1, "Ticker ",TestOperator.StringExact),
web.cell(1, 2,"Company ", TestOperator.StringExact),
web.cell(2, 1, "ORCL*", TestOperator.StringWildCard),
web.cell(2, 2, "Oracle", TestOperator.StringExact)));
Identifies a text area by its recorded ID and path.
Format
The web.textArea method has the following command format(s):
web.textArea(path);
web.textArea(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Clicks on a text area specified by its recorded ID and path and sets the text in the text area.
getVariables().set("taPath", "/web:window[@index='0' " + "or @title='Input Samples']" + "/web:document[@index='0']" + "/web:textarea[@name='myTextArea' or @index='0']"); web.textArea(84, "{{taPath}}").click() web.textArea(85, "{{taPath}}").setText("text area text");
Identifies a text box by its recorded ID and path.
Format
The web.textBox method has the following command format(s):
web.textBox(path);
web.textBox(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Clicks on a text box specified by its recorded ID and path and sets the text in the text box.
//plain text box getVariables().set("tbPath", "/web:window[@index='0' " + "or @title='Stocks']" + "/web:document[@index='0']" + "/web:form[@id='loginform' or @name='loginform' " + "or @index='0']" + "/web:input_text[@id='login' or @name='login' " + "or @index='0']"); web.textBox(9,"{{tbPath}}").click(); web.textBox(10, "{{tbPath}}").setText("text box text"); //password box getVariables().set("tbPath", "/web:window[@index='0' " + "or @title='Stocks']" + "/web:document[@index='0']" + "/web:form[@id='loginform' or @name='loginform' " + "or @index='0']" + "/web:input_password[@name='password' or @index='0']"); web.textBox(11, "{{tbPath}}").click(); web.textBox(12, "{{tbPath}}").setPassword(deobfuscate("wKAUCoeFpUbXlwTYN9lp7A=="));
Perform the web accessibility testing to the active window and generate the report to results folder. This API will validate accessibility of the current active page.
Report data will be stored in: results\\SessionN\\AccessibilityReport.
Format
The web.validateAccessibility method has the following command format(s):
web.validateAccessibility();
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Perform the web accessibility testing to the active window and generate the report to results folder.
web.window(1, "/web:window[@index='0' or @title='www.example.com']")
.navigate("http://www.example.com");
web.window(4, "/web:window[@index='0' or @title='Stocks']")
.waitForPage(null);
web.button(5,"//web:input_submit[@id='Login']")
.click();
web.validateAccessibility();
Searches the HTML contents of all documents in all browser windows for the specified text pattern, reporting a warning if the test fails.
This method will never cause a script to fail, regardless of the text matching test error recovery settings. Use web.assertText to make the script fail when the test fails.
Format
The web.verifyText method has the following command format(s):
web.verifyText(testName, pattern, sourceType, textPresence, matchOption);
Command Parameters
a String specifying the test name.
a String specifying the pattern of test.
a Source enum specifying the location to match, either the source HTML or the HTML excluding markup tags.
a TextPresence enum specifying either PassIfPresent or FailIfPresent, depending on if you want the text to be present or not.
a MatchOption enum specifying either Exact, RegEx, or Wildcard, depending on match type.
Example
Adds a Verify only, never fail Text Matching tests for Display Content and Raw HTML respectively.
myTextMatchingTest1
passes if the text to match string is present in the Display Content and matches exactly.
myTextMatchingTest2
fails if the text to match string is present in the source HTML and matches the Wildcard.
web.verifyText("myTextMatchingTest1", "FMStocks Customer Login", Source.DisplayContent, TextPresence.PassIfPresent, MatchOption.Exact); web.verifyText("myTextMatchingTest2", "FMStocks Customer Log*", Source.Html, TextPresence.FailIfPresent, MatchOption.Wildcard);
Waits for an object to exist before timing out.
Format
The web.waitForObject method has the following command format(s):
web.waitForObject(path, timeout);
Command Parameters
a String specifying the object path.
a timeout value to find an object, in milliseconds.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Waits for the object specified by its path. Timeout after 5 seconds.
getVariables().set("obPath", "/web:window[@index='1']" +
"/web:document[@index='1']" +
"/web:form[@id='loginform' or @name='loginform' or @index='0']" +
"/web:input_submit[@name='LoginButtonADD']");
web.waitForObject("{{obPath}}", 5000);
Identifies a window by its recorded ID and path.
Format
The web.window method has the following command format(s):
web.window(path);
web.window(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Identifies an xml document by its recorded ID and path.
Format
The web.xmlDocument method has the following command format(s):
web.xmlDocument(path);
web.xmlDocument(recId, path);
Command Parameters
a String specifying the object path.
the ID of a previously recorded navigation, used for comparison purposes.
Throws
represents an exception that may be thrown during the execution of a script where the exception should be reported to an end user through the controller.
Example
Performs an action on an open xml document specified by its recorded ID and path.
getVariables().set("recHtml", web.xmlDocument(1, "/web:document[@index='0]'").getHTML()); info("The HTML string is: {{recHtml}}"); getVariables().set("recUrl", web.xmlDocument(2, "/web:document[@index='0]'").getRecordedURL()); info("The URL is: {{recUrl}}");