Get request headers to validate analytics in a website - selenium

I have to perform testing through selenium webdriver(java) on Site analytics of a website. All the attributes, values are sent to the analytics toold via URL header request. I would like to capture the request alone so that I can perform my manipulations and extract the attributes and their values.
I tried BrowserMob tool. It's getting me the entire traffic in the form of HAR file. is there a way to extract the request alone?
I tried server.setCaptureHeaders(true); but it didn't help much as I see a whole bunch of URLs in the HAR. I'm interested in only one that is sent to the analytics website. There is a URL thats sent as a request behind the scene. Few analytics plugin are able to exactly get the request URL and extract the attribute values but I can't automate through those plugins.
Or is there a way to rip off only certain requests from HAR?

BMP is a great tool. You can only create a new har before the request is sent and read it after this. You can iterate through the dict it returns and find the request you need

Related

Data storage after API call form Postman/SoapUI

I need to create an automated test-setup for some webservies, and plan to use SoapUI or Postman for that. My question is pretty basic. What happnds to the data after a request is made?
E.g. if the response contains data from a system, and display it in the Postman UI, will Postman store the response? Or what will happnd to it after the request?
I'm asking for security purpose and I was not able to find a concrete answer myself. Thank you in advance.
Postman provides us the explicit ways to store data or not. When you try to run a collection then in the settings we can specify if we want to store responses, cookies, etc or not. Configure it as per your need.
As per the official site
"Postman does not track any content of your requests/responses."
Under File--> settings
You can even avoid using the cloud version if you don't want to sync up things
Re SoapUI...
If you call a service once, then the data remains in the UI. If you run a second or third time, then only the last response is shown in he UI.
Once you close SoapUI, the request and response data is gone.
However, you can save the data from every request and response by using a datasink step, should that be what you want.

How to get csrf token in Jmeter to use for log-in

I'm trying a log-in scenario for a page, but it's getting an error because of the csrf_token and other dynamic parameters that are being generated every time I run the test. How do I get these csrf_token and these parameters to use in my test?
Please see image below.
Request Header parameters
Jmeter Parameters
Error detail
Thanks,
You need to extract it from the previous response using a suitable Post-Processor, store it into a JMeter Variable and replace the recorded value with the variable.
The process is known as "correlation" and there is a lot of information on the topic over the web, for example How to Load Test CSRF-Protected Web Sites article would be a good starting point.

How to access all text from a website, including the a tag?

I'm trying to extract all the article text from the following site:
https://www.phonearena.com/reviews/Samsung-Galaxy-S9-Plus-Review_id4494
I tried findAll(text=True) but it extracts lot of useless information.
So I did findAll(text=True, recursive=False) but it ignores text data in certain tags like ? What's the most effective way of extracting the text in this case?
The website seems to be javascript protected. It loads the body content when requests already retrieved the http response. You need to simulate a real page request. With the python module Selenium Webdriver it would be possible.

scrapy not visiting url after #

I am writing a scraper for a site. however weird thing is happening, it's not visiting the URL i supply to him. Rather it visits the base url of the website.
I searched on the internet and came to know that, scrapy would ingnore URL after #, I need to indentify the Ajax request being sent and mimic that.
However the problem is. the response of the Ajax request comes as json response. it's not a html content. Would someome please help me how to deal with it.
Following is the url
https://www.buildersshow.com/Search/Exhibitors.aspx#showID=11&state=160&tabname=name
If you investigate the AJAX requests that the page makes, identify the request you need to make and get your response, it should be JSON contained in the response body. To parse it and get your data of interest, use the json decoder/encoder module. Something like this:
import json
mydata = json.loads(response.body)
info = mydata['somekey']
subinfo = mydata['somekey']['subkey']
And so forth. Make sure to handle the json decoder the proper way, it would be best to read the official documentation first.

Add a header to a page request using GET?

I have a vb.NET App that uses System.Net.WebClient to query an API. I'm able to get the information I'm requesting just fine.
The people that supply the API are requesting that I
"set a custom User header when requesting data to determine the source application."
Am I supposed to pre-send something first, or append something to the url for the WebClient to processes? The API only accepts get requests and it doesn't have a parameter for an identification.
I'm stuck in terminology here. A search for that phrase, here, came up with server-side topics so I don't know what to look for. Can someone translate?