I have a selenium scraper that open the site and login in to it. The site has been written by react or react native and the data of the page get from API.
I want when the selenium open the browser and login to it capture the Get and Post Request too.
I want to get the specific header from one of the API request.
I have tried many way such as browsermobproxy (not compatible with .net 6 ) and other ways but no one can’t solve my problem.
I have tried this too :
ChromeOptions options = new ChromeOptions();
options.AddArgument("user-data-dir=C:\Users\Test\AppData\Local\Google\Chrome\User Data");
// Create a new ChromeDriver object.
IWebDriver driver = new ChromeDriver(options);
// Navigate to the target website.
driver.Navigate().GoToUrl("https://test.com/");
// Get the network requests.
List<NetworkRequest> requests = driver.GetNetworkRequests();
// Print the request details to the console.
foreach (NetworkRequest request in requests)
{
Console.WriteLine($"Request URL: {request.Url}");
Console.WriteLine($"Request Method: {request.Method}");
Console.WriteLine($"Request Status Code: {request.StatusCode}");
Console.WriteLine($"Request Headers:");
foreach (var header in request.Headers)
{
Console.WriteLine($" {header.Key}: {header.Value}");
}
Console.WriteLine();
}
// Close the browser.
driver.Quit();
2
Answers
I Use this and it solve my problem
You can use devtools with chrome driver