How can I get the HTTP request data? - java

I'm testing with JMeter and I need the HTTP request data to make that.
I tried to see that information in F12 Network of Chrome browser, but it doesn't appear the information there.
Someone knows how can I get that information?

You can't get the request because the browser refreshes the network tab when you go to another page. But you can persist these requests marking the option Preserve Logs, like so:
Image before request, with the checkbox checked:
After request, persistent logs:
You can see more information about the network tab here

The easiest way is to capture HAR file in the Chrome Developer Tools, it will have all the information for the request data including parameters, headers, cookies, etc.
Once done you will be able to inspect it with i.e. HAR Analyzer or simply convert it into a JMeter .jmx script

The best way to capture HTTP Requests is by using JMeter's Proxy.
If you try to inspect network in browser and construct JMeter script manually it takes lot of efforts, Alternatively you can just set your JMeter as a proxy server and capture your browsers network traffic.
Follow this post for more information on how to setup proxy in JMeter and record web applications.

Related

JMeter correct location to input a web url? - (Response time required)

JMeter correct location to input a web url?
Im new to Jmeter and need to get the reponse of a given url
I need to use the URL address and not the IP address
Is the following setup correct?
Your setup is fine, if hostname is blank it will be populated from the HTTP Request Defaults (same for the other fields). You can override the "defaults" on HTTP Request level if required.
Few more recommendations:
In the "Advanced" tab of the HTTP Request Defaults tick "Retrieve All Embedded Resources" and "Parallel Downloads" boxes, this way JMeter will request extra resources which are referenced in the HTML like images, scripts and styles (this is what real browsers do when rendering the pages)
Add HTTP Cache Manager to your Test Plan. Real browsers download aforementioned resources, but they do it only once, on subsequent requests images and so on are being returned form browser cache. HTTP Cache manager represents this cache and respects the relevant control headers
Add HTTP Cookie Manager which handles user sessions and deals with cookie-based authentication
Add HTTP Header Manager to send browser-like headers like Content-Type, User-Agent, etc.
See How To Make JMeter Behave More Like A Real Browser for above configurations explained in details.

get fiddler logs from a connection with selenium java

my company have a bunch of websites that some of them redirect and some do not.
my job is to automate with selenium java to find which one is redirecting get the fiddler log and send it to the advertiser responsible
i tried to find a way to get the log from the fiddler in an automated way
(.saz file or even text log) but i could not find any way to automate that
p.s.
if there's another way to get all the connections from a proxy server without fiddler it will be great too. but i need everything that the fiddler gets (the web view, the headers, the raw)
any help?
Fiddler should be capturing all traffic.. and logs can be saved in an automated way...(you could also write custom rule if you have specific need).. I have done this before so i know it works
The log (saz or txt) has all required information. Different views by fiddler shows you formatted and organized info...

How to view HTTP POST/GET responses in a browser?

I'm learning how to send HTTP requests in Java. Is there a way to visually see the POST/GET responses in a browser? UI and all? I know how to perform the requests in Java and receive html printed out in the console, but it would be easier for me to just see the website itself in the browser.
do i need a plugin? or do i need to open up a socket connection and do something with localhost?
Sorry if this question is a duplicate/is not clear: I'm very new to this.
In Firefox, you can press Ctr+Shift+Q and click on Network. Once you visit a page, it will show you the request in the list area. If you click on a request, it will show you the request and response headers. Very useful for debugging sites. I hope that's what you were asking. BTW, I have Firefox 30.0 in Win 8.1. I don't know about previous versions.
EDIT: If you want to intercept the HTTP request generated from Java, you can use Fiddler. It may have what you're looking for.
I use Firebug for firefox. It shows requests, responses, and all headers in real time (with measuring latency) so it's really convenient for development. It's add-on: https://addons.mozilla.org/en-US/firefox/addon/firebug/
You should be able to console.log the object and in most browsers click on the object in development mode, expand it, and see all of its properties.
In Chrome you can right click -> Inspect Element and go to the Network tab. Refreshing the page will begin tracking the page you are on. When you send out requests, the request log will record them.

How to programmatically logon to a URL, keep the session, and browse around to different pages

I am working on small Java project to programmatically connect to a website with username/password, after login, browse to different links on the site to download some data. First, I need to connect to the website with username/password,
second, while I keep the session open, go to other links to download data.
How do I do this in Java?
Any help will be highly appreciated!
Check out the Apache HTTPClient, it can do all this for you.
Edit: Apache HTTPClient has authentication and cookie handling features included, which will save you a lot of work doing this yourself.
If you want to extract some data HtmlUnit can help you a lot it can manage the authentication and also help you with data extraction.
Investigate with your browser how the web page submits the username/pass data? HTTP Form POST, Ajax, etc..? Use a plugin like Firebug to see network traffic.
You can use URLConnection to create HTTP requests. You will neet to simulate a username/pass login and remember the cookie for use in consequent HTTP requests to simulate a session. Here are some examples: send HTTP POST request, get a cookie, send a cookie.

Using HTTP OPTIONS to retrieve information about REST resources

This problem relates to the Restlet framework and Java
When a client wants to discover the resources available on a server - they must send an HTTP request with OPTIONS as the request type. This is fine I guess for non human readable clients - i.e. in code rather than a browser.
The problem I see here is - browsers (human readable) using GET, will NOT be able to quickly discover the resources available to them and find out some extra help documentation etc - because they do not use OPTIONS as a request type.
Is there a way to make a browser send an OPTIONS/GET request so the server can fire back formatted XML to the client (as this is what happens in Restlet - i.e. the server response is to send all information back as XML), and display this in the browser?
Or have I got my thinking all wrong - i.e. the point of OPTIONS is that is meant to be used inside a client's code and not meant to be read via a browser.
Use the TunnelService (which by default is already enabled) and simply add the method=OPTIONS query parameter to your URL.
(The Restlet FAQ Q19 is a similar question.)
I think OPTIONS is not designed to be 'user-visible'.
How would you dispatch an OPTIONS request from the browser ? (note that the form element only allows GET and POST).
You could send it using XmlHttpRequest and then get back XML in your Javascript callback and render it appropriately. But I'm not convinced this is something that your user should really know about!

Categories