Selenium series: capturing HAR files
Blog post from Octopus Deploy
Matthew Casperson's article, published on October 2, 2018, explores the creation of a Selenium WebDriver test framework with a focus on generating and utilizing HTTP Archive (HAR) files. These files, which are JSON-formatted logs of a browser's interaction with web applications, can be captured using Chrome developer tools and analyzed with tools like HAR Analyzer to inspect HTTP response codes and network call timings. The article details methods for capturing and saving HAR files using BrowserMob proxy in a test framework, highlighting the implementation of methods such as captureHarFile() and saveHarFile() in the AutomatedBrowser interface and BrowserMobDecorator class. Furthermore, it explains how to capture comprehensive HAR files with additional network data by using captureCompleteHarFile(), which expands the default capture to include headers and cookies. The article emphasizes the importance of HAR files in diagnosing web application errors and understanding performance bottlenecks, and it concludes with a note on the potential for BrowserMob to not only record but also modify network traffic in future posts.