Skip to content
Advertisement

Java Selenium get JSON response body

I using Java with Selenium webdriver and I wondering is it possible to get JSON body response? I asking because it is possible to get JSON request body using this code:

JavaScript

but I can’t get body from response but response exist also in this log. Is any way to get response body?

Advertisement

Answer

Edit-2

Because of a open issue with Geckodriver, https://github.com/mozilla/geckodriver/issues/764

So you need to use a workaround and do what GeckoDriver does in background for you

JavaScript

Edit-1

Since you want to do this in Java. You need to use BrowserMobProxy libs for Java and below kind of code should work for you

JavaScript

Original Answer

You need setup a BrowserMobProxy on Firefox. Below code will work for you

JavaScript

This will give output like below

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement