Record the API call following the activation of a button

Scenario: We have a software that generates reports based on selected filters (checkboxes, radio buttons, dropdowns, text boxes) from a form. When a user clicks the "generate report" button, an API Request Header request is triggered and a downloadable pdf/csv report is generated.

I can view these requests in the browser's Network tab under:

Headers[tab] -> Request Headers - :path api/path/to/download/pdf

Headers[tab] -> Request URL: full/api/path/url/to/download/pdf

Is it possible to capture these request URLs using JavaScript or Java?

Answer №1

If you need to capture web requests, utilizing a proxy is recommended. Browsermob proxy is commonly used with selenium.

Take a look at this example provided on :

// initiating the proxy
proxy = new BrowserMobProxyServer();
proxy.start(0);

// acquiring the Selenium proxy object - org.openqa.selenium.Proxy;
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

// setting it as a desired capability
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
    
//setting chromedriver system property
System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe");
driver = new ChromeDriver(capabilities);
    
// enabling more detailed HAR capture, if needed (refer to CaptureType for complete options)
proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);

// creating a new HAR labeled "seleniumeasy.com"
proxy.newHar("seleniumeasy.com");

// navigating to seleniumeasy.com
driver.get("https://seleniumeasy.com/");

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to resolve preventDefault issue on else condition during form submission in CoffeeScript on Rails 4

After submitting a form, I have implemented a code to prevent the page from refreshing and perform different actions based on certain conditions. Everything works as expected except for one scenario where the page still refreshes after executing the ELSE c ...

Finding the third child element of a grandparent using XPath

This example showcases my DOM structure: <div id="x-auto-2121" class="GI05A-4CEKC"> <div class="GI05A-4CBKC GI05A-4COJC GI05A-4CGKC GI05A-4CFKC"> <img style="height: 18px; width: 17px;" src="https://someserver.com/clear.gif"/> ...

Issue with Angular 2 (Ionic 2): Struggling to properly display Component within Page

I have successfully created an Angular 2 Component: import {Component, View} from 'angular2/core'; @Component({ selector: 'sidemenu' }) @View({ templateUrl: 'build/pages/menu/menu.html', }) export class Menu { } Howev ...

Struggling to store a new user in Firebase Database

I have been researching extensively and am struggling to get any data to show up in the firebase database. I am aiming for this specific structure: "my-app-name": { "users": { "uid-of-user": { "email": "<a href="/cdn-cgi/l/email ...

methods for extracting data from nested JSON arrays in Android

Can anyone assist me in fetching the URL from the JSON array thumbnail_images? The URL I need is nested inside another array called medium_large. I have successfully retrieved the URL from the following JSON: "attachments": [ { "id": 367, "url": ...

Equivalent of SQL Select in MongoDB with node.js

As a newcomer to node.js and mongodb, I find it frustrating that querying data with 'SELECT * FROM table' in php produces an array or array of objects, while in node and mongo, it requires so much unnecessary code. To simplify this process, I cre ...

Modify the JS/JQuery variable by utilizing the data entered into an HTML input field

I have implemented a javascript/ajax request on my advanced search page. <script> // window.setInterval(function() // { $(function () { var SearchTerm = '<?php echo $_POST['Search']; ...

Downloading large video files using xhr in Chrome through JavaScript

There is a known issue causing Chrome tabs to crash when attempting to download large files (>50-80 Mb) using an ajax request (source: http://code.google.com/p/chromium/issues/detail?id=138506). Although Chrome is the only browser currently supporting ...

Retrieving complete credit card information with the help of JavaScript

I've been grappling with extracting credit card data from a Desko Keyboard, and while I managed to do so, the challenge lies in the fact that each time I swipe, the card data comes in a different pattern. Here is my JavaScript code: var fs = require ...

Confirming the existence of a folder with AngularJS

Currently, I am attempting to determine if a folder exists so that I can make decisions on which files to include using ng-include. This is what I have so far: $scope.isVisible = { buttons: checkForClientOverwride('buttons'), it ...

Storing and Retrieving Mongoose Data Using Nested Schemas, References, and Promise Functions

I have a question regarding saving and retrieving documents with nested schema references in Mongoose. When I try to save a document with nested schema refs, and then retrieve it later, the required nested field is not included unless I populate it in the ...

The `modelName` model cannot be recompiled as it has already been written

Issue with Updating partnerCode Model After Compilation. I have a file called models/partnerCode.js var mongoose = require('mongoose'); var Schema = mongoose.Schema; var partnerCodeSchema = new Schema({ email: String, used: {type: Numb ...

The issue with json arises when utilizing $.ajax without the definition$

Attempting to make this code work properly Javascript $.ajax({ url: '/endpoint/json/', //Update the path to your JSON file. type: "post", dataType: "json", //Remove the "data" attribute if not needed. data: { ...

Working with JSON data in javascript

While trying to parse JSON data from a server, I came across a strange issue. The data consists of rows of data - essentially a list of lists - and it looks something like this: [[1,2,3],[4,5,6],[7,8,9]] When viewing the JSON data in FF (using Firebug), ...

Error encountered in Webpack configuration while using html-webpack-plugin to generate index.html file

I've been experimenting with webpack to bundle project JS files. My goal is to generate an index.html file under the output dist folder using webpack. To achieve this, I followed the instructions provided in the webpack documentation and installed "h ...

After the "div" tag comes the magic of AJAX, PHP, and JAVASCRIPT, replacing

My Ajax implementation is successfully displaying the selected content on a div, but unfortunately, everything that comes after the div is getting replaced by this output. I am unsure of why this is happening and how to resolve it. If you have any insigh ...

Choosing Drop Down Options Dynamically with Jquery

I have a total of 4 Drop Downs on my page. https://i.stack.imgur.com/6tHj5.png Each drop-down initially displays a "--select--" option by default. Additionally, each drop-down has a unique ID assigned to it. The second drop-down is disabled when the abov ...

What is the best way to use lodash to group objects that contain nested objects?

Currently utilizing Typescript in conjunction with Lodash! Upon retrieving data from the database, here is the resulting output: [ { "unitPrice": 0.01, "code": "92365524", "description": "Broto gr ...

Creating a dynamic dropdown menu that changes based on the selection from another dropdown menu

I'm working on a project that requires users to make specific selections in dropdown menus that are interconnected. Does anyone know how to set up a form so that the options in dropdown menu #2 change based on what the user selects in dropdown menu #1 ...

Is there a limit of 55 lines when using readline in Node.js? How can one effectively read input from standard input in Node

Having a bit of trouble with my code here. I'm trying to read input from the terminal, save it to an array, and then print it all out again. The issue arises when I try to paste in more than 55 lines of text - the program only prints the first 55 line ...