0

I'm trying to use BrowserMob Proxy with Selenium in C#.

I've tried this solution here: http://www.adathedev.co.uk/2012/02/automating-web-performance-stats.html

And my code looks like this:

Server server = new Server(@"path_to\\browsermob-proxy.bat");
server.Start();
Client client = server.CreateProxy();
client.NewHar("test");

var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy };
var profile = new FirefoxProfile();

profile.SetProxyPreferences(seleniumProxy);
IWebDriver driver = new FirefoxDriver(profile);

When I run the test I get the following error:

System.Net.WebException: The remote server returned an error: (404) Not Found.

It fails at the third line.

Any suggestions on how to get this working?

luk2302
  • 46,204
  • 19
  • 86
  • 119
Archpoet
  • 55
  • 1
  • 6

3 Answers3

0

If you can post a more detailed stack trace, that would be useful, along with the remote host you're trying to connect to. In the meantime a few things to try are:

  • Check the address you're requesting. It seems you're getting a 404 -- can you hit it through a browser without the proxy?
  • Make sure browsermob-proxy.bat is installed at the path on line 1 (is it really in a subdirectory of the working directory called "path_to"?)
  • Check your write permissions in the temp directory, which is %TEMP% or %TMP% on Windows. BMP writes temporary files there.
  • Grab the latest source and build the .bat file. The instructions are on the browsermob-proxy github page at the bottom (under Creating the batch files from source).

Hope that helps!

Jason Hoetger
  • 5,650
  • 2
  • 13
  • 14
0

This is most likely because your Jetty service is not actually running, did you get a message from BrowserMob batch file saying it couldn't run? In my case it was a situation where the port (by default is set to 8080) but I had something else listening on that port. To fix this, you can pass an optional port number.

var server = new Server(@"C:\path\to\bin\browsermob-proxy.bat", 9090);
Chris Hawkes
  • 9,842
  • 6
  • 47
  • 60
0

I had same problem on python. When I had tried to get content of localhost:8080 I got 404 error. It turned out that my other application was using same 8080 port. So I found PID typing in cmd: netstat -o -n -a | findstr :8080. Then I just terminated process with this PID and browsermob gave me well HAR.