Skip to content
Go back

Test Automation - How To Attach Public IP Adress to Allure report using Pytest and Requests

Published:

Introduction

In this article, I will explain how to attach our public IP address to Allure report using Pytest and Requests the work on this project was developed together withElias Shourosh.

link to the project.

The technological stack used to implement the solution is:

Programing language: Python

Testing Framework: pytest

Reporting Framework: Allure

HTTP Library: Requests

Why should we attach our IP address to the report?

  1. This is done mainly for debugging purposes - if the automation fails, we can filter the logs in a centralized logging system like Amazon CloudWatch.
  2. The IP also helps to detect a machine while running a parallel run with multiple containers or VMs.

Implementing the Solution

We will write a simple function that will do a GET request and return the IP address from the following AWS service: http://checkip.amazonaws.com

def get_public_ip():
    return requests.get("http://checkip.amazonaws.com").text.rstrip()

We will use this method to attach the IP to the allure report in case of test failure:

allure.attach(get_public_ip(), "public ip address", attachment_type=allure.attachment_type.TEXT)

Now each failure will contain our public IP

No alt text provided for this image

Happy testing!


Suggest Changes

Have a challenge? Let's Talk


Previous Post
Test Automation - How To Build a CI/CD Pipeline Using Pytest and GitHub Actions
Next Post
Test Automation - How To Create an Independent Automation Infrastructure using GitHub Actions