This chapter provides a complete listing and reference for the methods in the OpenScript AmfService Class of AMF Load Module Application Programming Interface (API).
The following section provides an alphabetical listing of the methods in the OpenScript AmfService API.
The following table lists the AmfService API methods in alphabetical order.
Table 4-1 List of AmfService Methods
Method | Description |
---|---|
Search the AMF contents of all documents in all browser windows for the specified text pattern. |
|
Post an AMF request to the AMF server identified by recID, description, and urlPath. |
|
Parses a value from the most recent navigation's contents and store it as a variable. |
|
Extract a value from the last retrieved response using XPath notation. |
|
Search the AMF contents of all documents in all browser windows for the specified text pattern. |
The following sections provide detailed reference information for each method and enum in the AmfService Class of AMF Load Module Application Programming Interface.
Search the AMF contents of all documents in all browser windows for the specified text pattern.
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.
The amf.assertText method has the following command format(s):
amf.assertText(testName, textToAssert, sourceType, textPresence, matchOption);
a String specifying the test name.
a String specifying the text to match on the page, or not match on the page if TextPresence says TextPresence.FailIfPresent.
an AmfSource enum specifying where to match the text, i.e. in the XML contents or HTTP response headers.
a TestPresence enum specifying either PassIfPresent or FailIfPresent, depending on if you want the test to pass or fail if the text to match is present or not.
a MatchOption enum specifying how the text to match should be searched on the page, such as using a regular expression, wildcard, or exact match.
if the assertion fails.
on any other failure when attempting to assert the text.
Adds Text Matching tests for Response Header and XML Content.
myTextMatchingTest1
passes if the text to match string is present in the XML Content and matches exactly.
myTextMatchingTest2
passes if the text to match string is present in the Response header and matches the Regular Expression.
myTextMatchingTest3
fails if the text to match string is present in the XML Content and matches the Wildcard.
amf.assertText("myTextMatchingTest1", "match this text string", AmfSource.Content, TextPresence.PassIfPresent, MatchOption.Exact); amf.assertText("myTextMatchingTest2", "jsessionid=(.+?)(?:\\\"|&)", AmfSource.ResponseHeader, TextPresence.PassIfPresent, MatchOption.RegEx); amf.assertText("myTextMatchingTest3", "match this *", AmfSource.Content, TextPresence.FailIfPresent, MatchOption.Wildcard);
Post an AMF request to the AMF server identified by recID, description, and urlPath.
Reads the XML postMessage
as a String, serializes it into an ActionScript (AMF) object and then makes a post to the urlPath
provided.
The amf.post method has the following command format(s):
amf.post(description, urlPath, postMessage);
amf.post(recId, description, urlPath, postMessage);
a String specifying a human-readable description of the operation which will be invoked on the server. Used for reporting and script display purposes only.
a String specifying the AMF endpoint on the server where all AMF requests are posted. For example: "http://server:8080/todolist-web/messagebroker/amf"
a String specifying an XML string containing the AMF message which will be posted to the urlPath.
the ID of a previously recorded navigation, used for comparison purposes. May be null.
Posts the xml postMessage as an ActionScript (AMF) object to the specified URL.
amf.post(10, "Click the button", "http://server-xyz:8080/openamf/gateway",
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
"<amf version=\"0\">" +
"<headers><header name=\"amf_server_debug\" required=\"true\"> " +
"<asobject type=\"NetDebugConfig\">" +
"<entry key=\"m_debug\" type=\"boolean\">true</entry>" +
"<entry key=\"coldfusion\" type=\"boolean\">true</entry>" +
"<entry key=\"error\" type=\"boolean\">true</entry>" +
"<entry key=\"amf\" type=\"boolean\">false</entry>" +
"<entry key=\"trace\" type=\"boolean\">true</entry>" +
"<entry key=\"httpheaders\" type=\"boolean\">false</entry>" +
"<entry key=\"recordset\" type=\"boolean\">true</entry>" +
"<entry key=\"amfheaders\" type=\"boolean\">false</entry>" +
"</asobject>" +
"</header></headers>" +
"<bodies>" +
"<body operation=\"org.openamf.examp.Test.getNumber\" response=\"/1\">" +
" <list><item type=\"double\">123.456</item></list>" +
"</body>" +
"</bodies>" +
"</amf>");
Parses a value from the most recent navigation's contents and store it as a variable.
This method honors the "Solve Variable Failed" error recovery setting. If "Solve Variable Failed" error recovery is not set to fail, then the script will continue running even if a non-optional variable cannot be solved.
The amf.solve method has the following command format(s):
amf.solve(varName, pattern, errorMsg, isOptional, sourceType, resultIndex, encodeOption);
a String specifying then name of the variable to create. Must not be null
.
a Regular expression pattern specifying what to extract from the most recent navigation's contents. May contain a transform expression. Must not be null
.
a String specifying an optional error message to display if the pattern cannot be solved. If null
, a meaningful error message is automatically generated.
True if the pattern does not have to be solved. If the pattern cannot be solved, the method quietly returns.
an AmfSource enum specifying where to match the text, i.e. in the XML contents or HTTP response headers.
an index value specifying the 0-based index of the specific result to retrieve if the pattern matches more than one value. If null
, all results will be added into the variables collection.
an EncodeOptions enum specifing the encoding or decoding operation to perform on the variable's value after solving the variable. A null
value is equivalent to EncodeOptions.None
.
if an error parsing the value.
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.
if the given pattern cannot be matched to the previous contents and the pattern is not optional.
Parse a value from the most recent navigation's specified source using a Regular Expression and store it in a variable. An optional error message returns if the pattern cannot be solved. The pattern is optional and does not have to be solved. Includes a result index value of 0 to specify it should retrieve the first match result.
amf.solve("flex.dsid",
"<entry key=\"DSId\" type=\"string\">(.+?)</entry>",
"DSId is a required field", true, AmfSource.Content,
0, EncodeOptions.URLEncode);
Extract a value from the last retrieved response using XPath notation.
The value will be stored to the given variable.
The amf.solveXpath method has the following command format(s):
amf.solveXpath(varName, xpath, lastValue, resultIndex, encodeOption);
a String specifying the variable name where the value will be stored. Must not be null
.
a String specifying the XPath to the value to parse from the last retrieved contents. Must not be null
.
an optional String specifying the recorded or last known value of the value about to be parsed. May be null
. For informational purposes only.
an index value specifying the 0-based index of the specific result to retrieve if the XPath returns multiple results. A null
value specifies that all results should be returned.
an EncodeOptions enum specifing the encoding or decoding operation to perform on the variable's value after solving the variable. A null
value is equivalent to EncodeOptions.None
.
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.
Extracts a value from the browser's last retrieved contents using XPath notation and stores it in the specified script variable. Encode or decode using the specified options.
amf.solveXpath("amf.formaction.loginform",
".//FORM[@name='loginform']/@action",
"default.asp", 0, EncodeOptions.None);
info("Login form = {{amf.formaction.loginform}}");
Search the AMF contents of all documents in all browser windows for the specified text pattern.
This method will never cause a script to fail, regardless of the text matching test error recovery settings.
Use amf.assertText to make the script fail when the test fails.
When playing back a script in Oracle Load Testing, always use Assertions; failed Verifications are NOT reported in OLT.
The amf.verifyText method has the following command format(s):
amf.verifyText(testName, textToVerify, sourceType, textPresence, matchOption);
a String specifying the test name.
a String specifying the text to match on the page, or not match on the page if TextPresence says TextPresence.FailIfPresent.
an AmfSource enum specifying where to match the text, i.e. in the XML contents or HTTP response headers.
a TestPresence enum specifying either PassIfPresent or FailIfPresent, depending on if you want the test to pass or fail if the text to match is present or not.
a MatchOption enum specifying how the text to match should be searched on the page, such as using a regular expression, wildcard, or exact match.
if the assertion fails.
on any other failure when attempting to assert the text.
Adds a Verify only, never fail Text Matching tests for Response Header and XML Content.
myTextMatchingTest1
passes if the text to match string is present in the XML Content and matches exactly.
myTextMatchingTest2
passes if the text to match string is present in the Response header and matches the Regular Expression.
myTextMatchingTest3
fails if the text to match string is present in the XML Content and matches the Wildcard.
amf.verifyText("myTextMatchingTest1", "match this text string", AmfSource.Content, TextPresence.PassIfPresent, MatchOption.Exact); amf.verifyText("myTextMatchingTest2", "jsessionid=(.+?)(?:\\\"|&)", AmfSource.ResponseHeader, TextPresence.PassIfPresent, MatchOption.RegEx); amf.verifyText("myTextMatchingTest3", "match this *", AmfSource.Content, TextPresence.FailIfPresent, MatchOption.Wildcard);