This repository contains Headless Form Automation testing scripts in Postman
It is owned and maintained by the Addons QA team.
Folder | Description |
---|---|
HeadlessForm | Contains scripts for Headless Forms Service API testing. This includes endpoinds for: Get Forms, Submit Form and Get Forms Submission. |
Data | Contains test data file for testing |
Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman collection directly from the command-line
- Refer to link [https://confluence.sso.episerver.net/download/attachments/2861024248/Install%20Newman%20for%20Postman%20to%20generate%20html%20report.docx?version=1&modificationDate=1652927482393&api=v2] to install newman and newman-reporter-htmlextra
You can run specific script from command line. Following are sample commands.
newman run “FormHeadless 1.0.0.postman_collection.json” --folder "Regression" -r htmlextra
newman run “FormHeadless 1.0.0.postman_collection.json” --folder "GetForms" -r htmlextra
newman run “FormHeadless 1.0.0.postman_collection.json” --folder "FormSubmission" -r htmlextra
- Note: You can specify the test folder to save time with option --folder "folderName"
- Get AlloyMvcTemplates and install Headless Forms Service.
- Pull latest code of https://github.com/episerver/automation-content-headless-forms-api
- Import file automation-content-headless-forms-api\Data\Headless.bak to the database(Using SQL Server >=2019)
- Add code to any Controller class (for example StartPageController.cs) to get form guid automatically:
[Route("/cms/GetContentGuid")]
// Get content guid (key) /cms/GetContentGuid?id=1
public string GetContentGuid(int id)
{
var contentRepository = ServiceLocator.Current.GetInstance<ContentRepository>();
var contentLink = new ContentReference(id);
var content = contentRepository.Get<IContent>(contentLink);
if (content != null)
return content.ContentGuid.ToString().Replace("-", "").ToUpper();
return "No content found";
}
- Build and deploy site.
Postman script is stored in folder automation-content-headless-forms-api/FormHeadless/
- Import script to Postman
- Copy Data\files to your Working directory which is defined on Postman. These folder contains upload files that some scripts used.
- From Collection variables, update these varriables corresponding to the site: url, username, password.
- Run script with Newman.