This is a migrated thread and some comments may be shown as answers.

Java API to Interact with Fiddler

1 Answer 640 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Ravichandran
Top achievements
Rank 1
Ravichandran asked on 28 Mar 2018, 05:11 PM

Hi, 

I am trying to get the HTTP/WS Calls from the browser driver using the proxy.  I have configured chrome driver to use the proxy as shown below.

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            // Create a new proxy object and set the proxy
            Proxy proxy = new Proxy();
           proxy.setHttpProxy("localhost:8888");
           proxy.setSslProxy("localhost:8888");
            //Add the proxy to our capabilities 
            capabilities.setCapability("proxy", proxy);
            //Start a new ChromeDriver using the capabilities object we created and added the proxy to
             driver = new ChromeDriver(capabilities);

If Fiddler is opened in my machine, it captures all the calls from the driver and i can export the calls manually. 

Is there any API for Java to interact with Fiddler so that I can start Fiddler before my execution starts and Export the Calls as HAR whenever I need and Close Fiddler once my execution gets complete. 

I found a jar Fiddler 2.3.3 in Maven repo but I don't know the usage of this jar. 

https://mvnrepository.com/artifact/org.apache.river/fiddler/2.2.3

can anyone help me on this?

Share me the java code samples to interact with Fiddler.

 

 

 

1 Answer, 1 is accepted

Sort by
0
Simeon
Telerik team
answered on 03 Apr 2018, 09:07 AM
Hi Ravichandran,

We support no Java API for Fiddler. However, you could try to start Fiddler in a different process. I believe that Java could do this. Then, there should be an ExecAction.exe file in the installation directory of Fiddler (%LOCALAPPDATA%\Programs\Fiddler) by default. This executable accepts arguments which are passed to the OnExecAction method in the FiddlerScript. For example, if you type in the terminal ExecAction.exe "log Hello from ExecAction!", this would write in the Fiddler's log "Hello from ExecAction!". If you type ExecAction.exe quit, this would close Fiddler. Of course, you could start the ExecAction process from Java the same way you started Fiddler and also pass the arguments which you need.

You could also add functionality into your OnExecAction method in the FiddlerScript to export the sessions. Some methods which you could use for this are FiddlerApplication.DoExport(string sExportFormat, Session[] oSessions, Dictionary<string, object> dictOptions, EventHandler<ProgressCallbackEventArgs> ehPCEA) where the export format in your case is "HTTPArchive v1.1" or "HTTPArchive v1.2", you could get the sessions with FiddlerApplication.GetAllSessions() method and add "Filename" key into the dictOptions argument.

Regards,
Simeon
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Neha
Top achievements
Rank 1
commented on 02 Aug 2021, 02:17 PM | edited

Hi Telerik Fiddler team,

The above answer still not clears my doubt on how to initiate fiddler in Java code snippet. 

Please let me know if there are any recent versions of fiddler as Java api which can be used to integrate with Java code.

Also, If there's any link to java code snippet doing above functionality would be helpful.

The following code provided in documentation is not working for me.

    System.setProperty("http.proxyHost", "127.0.0.1");
    System.setProperty("https.proxyHost", "127.0.0.1");
    System.setProperty("http.proxyPort", "8888");
    System.setProperty("https.proxyPort", "8888");

 

Thanks,

Neha

 

Nick Iliev
Telerik team
commented on 03 Aug 2021, 10:25 AM

Both Fiddler and Fiddler Everywhere are acting as system proxies, and no particular Java configuration is needed from the Fiddler side. However, you need to configure either the Java application or the JVM to respect the Fiddler proxy (which by default won't be the case). Check the settings described in the articles below:

FIddler Classic and Java apps: https://docs.telerik.com/fiddler/configure-fiddler/tasks/configurejavaapp

Fiddler Everywhere and Java apps: https://docs.telerik.com/fiddler-everywhere/knowledge-base/configure-java-app-with-fiddler-everywhere

 

 

Tags
Fiddler Classic
Asked by
Ravichandran
Top achievements
Rank 1
Answers by
Simeon
Telerik team
Share this question
or