An open API service indexing awesome lists of open source software.

https://github.com/antonyhaman/har-capture-extension-selenium

Junit5 extension for Selenium and Allure that captures browser's HTTP activity
https://github.com/antonyhaman/har-capture-extension-selenium

Last synced: 7 months ago
JSON representation

Junit5 extension for Selenium and Allure that captures browser's HTTP activity

Awesome Lists containing this project

README

          

# har-capture-extension-selenium [![](https://jitpack.io/v/kotvertolet/har-capture-extension-selenium.svg)](https://jitpack.io/#kotvertolet/har-capture-extension-selenium)

Junit 5 extension for Selenium Webdriver and Allure that captures HTTP activity of browser and stores it into [HAR](https://en.wikipedia.org/wiki/HAR_(file_format)) file attached to Allure report. Analazying HAR files may be very useful for finding bugs and it's root cause especially when the problem can't be easily reproduced or happens from time to time.

## How does it work?

When properly set, the extension starts a proxy server that captures outcoming HTTP requests and starts a chrome instance which is set to use previously created proxy, after the test execution HAR file with HTTP requests attaches to Allure report:

![](https://github.com/kotvertolet/har-collector-junit5-extension/blob/master/screenshots/har_allure_report.jpg)

HAR file can be viewed with various services like [this](http://www.softwareishard.com/har/viewer/):

![](https://github.com/kotvertolet/har-collector-junit5-extension/blob/master/screenshots/har_viewer_screenshot.jpg)

## How to use

### Installation
Add [jitpack](https://jitpack.io/) repository to your pom.xml:
```xml


jitpack.io
https://jitpack.io

```
Add dependency to your dependencies section:
```xml

com.github.kotvertolet
har-capture-extension-selenium
LAST_VERSION

```
Alternatively, you can copy HarCaptureExtension.class into your project directly.

Then, in your BaseTest(AbstractTest, etc) initialize extension as following:
```java
private static final ChromeOptions chromeOptions;
static {
chromeOptions = new ChromeOptions();
chromeOptions.addArguments("start-maximized");
}

@RegisterExtension
static HarCaptureExtension harCaptureExtension = HarCaptureExtension.builder()
.addCapabilities(chromeOptions).build();
```
Then initialize your webdriver instance with your ChromeOptions(FirefoxOptions, etc). That's it.

## Requirements
Junit5, Selenium Webdriver, Allure