Since the HAR will return the JSON we need, we just need to parse the JSON returned to get what we want.
Using the project we created previously, we are going to add a few more lines to get what we want.
We need tell Selenium WebDriver that we have a proxy that it has to use. We do that with:
We need to tell the proxy to create a new HAR file for us. We do this by adding the following line:Proxy.newHar("PageName"); // PageName is the name of the page we want to capture
We then need to load a page, we can do this by clicking on a link calling get().
Now we need to call proxy.getHar(). This will return the HAR that we wanted.
Your code should look like this:
And your HAR, once put through a JSON Viewer should look like this:
What just happened?
We have just managed to capture the network traffic while we are running our tests. This can be really useful if you want to see if there are any 404 responses when we are loading our application under test. This can be useful if you are moving things about or if you are doing a smoke test after you have deployed your application to production.
Pop quiz - capturing Network Traffic
What is the name of the JSON format for showing network traffic?
What is the call that tells BrowserMob Proxy to start recording the traffic?
Have a go hero - doing more with BrowserMob Proxy
Now that we have managed to get the proxy started and managed to record the network traffic that is going through to the browser, let us have a look at getting the proxy to slow down the time that a response takes to get through. BrowserMob Proxy supports this and Intellij will be able to help with what parts of the API to use.
Selenium Related Interview Questions
|SILK TEST Interview Questions||QTP Interview Questions|
|JMeter Interview Questions||Automation Testing Interview Questions|
|Software testing Interview Questions||JUnit Interview Questions|
|TestNG Interview Questions||SAP Testing Interview Questions|
|Selenium WebDriver Interview Questions||Selenium IDE Interview Questions|
|QUnit Testing Interview Questions||Performance Testing Interview Questions|
|Hadoop Testing Interview Questions|
Getting Started With Selenium Ide
Overview Of Selenium Webdriver
Working With Webdriver
Getting Started With Selenium Grid
Advanced User Interactions
Working With Html5
Migrating From Remote Control To Webdriver
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.