Last updated: Jun 06, 2018 17:14
As some of you know Perfecto provides the functionality that enables you to Generate and Analyze HAR files. If you want to automate the process of the HAR files downloading this article is for you.
Let’s start with the prerequisites:
- You need to add these lines to your code obtain the executionID, which will later be used as anchor for finding the test ID:
Capabilities caps = driver.getCapabilities();
String externalID = (String) caps.getCapability("executionId");
For your convenience of testing you can print it like this:
System.out.println("externalID: " + externalID);
- You need to have a security Token, providing you with the ability to authenticate to your cloud.
- Follow this article on how to generate the HAR file. Stop upon reaching the “Retrieving the HAR file” part as the mentioned download method is manual.
- For my testing purposes I have installed Postman.
Having the prerequisites all set you can now continue:
To download the file in an automated manner (Let’s see how I have done with the help of Postman):
- Go for an HTTP GET with the following data:
- URL: https://<your-cloud>.reporting.perfectomobile.com/export/api/v1/test-executions
Value: your security Token
- Click on “New”:
- Select “Request”:
- Fill up the Name and select a Collection:
- Click “Save to <your Collection>”:
- Enter the URL https://<your-cloud>.reporting.perfectomobile.com/export/api/v1/test-executions (change <your-cloud> with the name of your cloud)
Click on “Header” and type the Key and the Value accordingly:
The result should look like this:
Here you have an “externalID”, like the one you have in the Prerequisites (you may need to search for it using the CTRL+F fucntion):
Determining the same “externalID” as the one in the code is essential for the determining the right test you are going to download the HAR file for.
Few lines below our “externalID” you will find “path” like this one (under “artifacts”):
This is the path you need!
When you follow it you will be taken to a ZIP file, you can download and extract. The HAR file is two levels below: