Network Workbench
Recommended guidanceIntroduction
Use Network Workbench is similar to understandthe networkAIQ behaviorValidation suite, but it is specific to Test Designer/JS Edit & Play.
Using Network Workbench, the requests can be extracted when it matches the URL which will be in a specific format like JSON, HTML, HTTP, MD5, PDF, etc., from the response to validate it or to create variables for future usage in the scripting.
The request has to be identified as a Regex that affectsmatches AIQa webfully testing,qualified APIURL, validation,Fully qualified means the protocol and troubleshooting. Network evidenceport should be reviewedprovided.
Example: ScenarioAppvance.ai Editor- steps,AI-driven, Outputunified Logs,test browserautomation behavior,software - The fully-qualified URL is https://www.appvance.com:443
In any case, it is always better to use .* that will match any protocol, domain, and applicationport.
Network logs.Workbench will create variables on the fly with extraction data instead of adding them to the locker.
Network Workbench used full JS Rhino for post-processing while AIQ post-processing is very limited.
Useful review pointsNavigation
You methods,can use the summary tab to search the validations and extractions using the search option.
Has option to disable or enable definitions, disabling all of them can be used to disable all the validations and extractions, etc.
Columns can be sorted.
The summary will provide details and links for the extractors and validations used.
Validations
Several validations could be added by providing the Validation Name, choosing what method, and providing the request details.
Responses can be validated for the following formats:
JSON
HTML
HTTP
MD5
Text
XML
String
CSV
Assertion Types:
Assert Equals
Not Equals
Contains
Does Not Contain
Less Than
Greater than
Less or Equal
Greater or Equal
Exists
In the above example, any request matching .*status.json should have a JSON object called config which should have a status codes,integer redirects,with a status code of 100.
Validations can be enabled or disabled using Disable/Enable Toggle.
Multiple validations can be added using Add button, Existing Validations can be updated using the Update button and timing.
Extractions
Extractions will create variables on the fly with extraction data instead of adding them to the locker. The variables are created with a $ at the beginning of the variable name, extraction will find any HTTP Request which matches .*/learning-area/javascript/oojs/json/superheroes.json
It will process the response as JSON and CSRFwill behavior.
Formats and Examples
JSON Format
Follows the same format as the AIQ JSON format. For this JSON,
{
"users":[
{
"username":"John"
},
{
"username":"Jane"
}
]
}
To get the first username ("John") the target should be
users[0].username
To get the second username ("Jane") the target should be
users[1].username
PDF Format
The example below will show how to extract the contents of a downloaded PDF page and perform some assertions on the same.
Steps for the scenario:
Click a pdf link that drivedownloads UIa statepdf file ("WCAG 2 at a Glance (PDF) A4")
Assert the word "Perceivable" in the downloaded pdf file.
4
If we inspect the element of the pdf, it will show the request which is what you will need to add to the extractor defining a variable.
Go to Network Workbench
Click the Extractions Tab and provide the mentioned values from the screenshot.
Target:
The document which will extract full text from the PDF
documentforms which will extract a JSON string with the name and value pairs of existing forms in the PDF document
page:### where ### indicate the page toindicates the text
regex:RRR: It will extract the full text, then it will provide the first string that matches the RRR regex. This could be generated with post-processing but is provided as a utility to speed up the process.
HTTP:
Header:Accept will return the value of the request header named "Accept"
CookieValue:expires will return the value of the request cookie named "expires"
TEXT:
Given the request's response is: "This is the ID Id=ABCDEF." then the TEXT extractor can use regular expressions as target values
Id=.* will return matching text (evaluating as regular expression): Id=ABCDEF.
HTML / XML:
Given the request's response is an XML or testHTML assertions.then the this extractors can use XPath expressions as target values
//*[local-name()='CountryCode']
//*[@id="cart-total"]
STRING Format
Given the request's response is: "This is the ID Id=ABCDEF." with 25 characters, then the STRING extractor can use
15,24 will return "Id=ABCDEF"
Id=,false will return "ABCDEF."
Id=,true will return "Id=ABCDEF."
Id=,24,true will return "Id=ABCDEF"
Id=,25,false will return "ABCDEF."
Network Workbench files will have a .netx extension.
Now how to use this file in JS / Test Designer?
Below is a Javascript example file that calls the .netx file and blocked-resourceperforms issues.
addNetworkLibrary("{ds}/PDFTest.netx");
prepareDomain("https://www.w3.org ");
navigateTo("https://www.w3.org/WAI/standards-guidelines/wcag/20/glance/ ");
click(link("WCAG 2 at a Glance (PDF) A4"));
log($pdfData);
assertContains($pdfData,"Perceivable");
Note: It is recommended to add addNetworkLibrary as the very first step, even before navigating to.
Example with zip Extractor
API Validation workbench also supports extracting the contents of a zip file and also checking the contents inside certain files and also checking asserting some of the metadata of the file (size of the file for example).
The below example shows how to test this scenario using a Network workbench.
Zip Content Extractor
Below is an example of a JS Script that affectnavigates performanceto a site to download the zip file and stability.
Best practices
Capturevalidates thesmallestcontentstimeofwindowa file inside the zip.prepareDomain("https://appvance-qa.s3-us-west-2.amazonaws.com");
navigateTo("https://appvance-qa.s3-us-west-2.amazonaws.com/qa/folder.zip");
wait(10000);
log("ZIP Content: "+$ZIPContent);
var text = $ZIPContent;
assertTrue(text.startsWith("Appvance"));
assertTrue(text.contains("$INSTALL_PATH"));JS Script
Network Workbench Definition
Output
Zip MetaData Extractor
Below is an example of a JS Script that
reproducesnavigates to a site to download theissue.Removezipor mask secrets before sharing network evidence.Compare failingfile andpassingvalidatesrunsthetometadataidentify(size)changedofrequestsaorfileresponses.Useinsidefindingsthetozip.improvewaits,addNetworkLibrary("{ds}/ZIPMetaData.netx");
assertions,
prepareDomain("https://appvance-qa.s3-us-west-2.amazonaws.com");
service
navigateTo("https://appvance-qa.s3-us-west-2.amazonaws.com/qa/folder.zip");
checks,
wait(10000);
or
log("ZIPenvironmentMETAsetup.DATA: "+$ZIPMetaData);
var data = $ZIPMetaData;
var size = JSON.parse(data).size;
assertEquals("726 bytes",size);JS Script
Network Workbench Definition
Output
Last updated:
OctoberMarch5,18,20262024If you have any feedback on this topic, please contact us at documentation@appvance.ai