lightbody / browsermob-proxy

A free utility to help web developers watch and manipulate network traffic from their AJAX applications.
http://bmp.lightbody.net
Apache License 2.0
2.17k stars 656 forks source link

Not able to run selenium and browser mob proxy tests with Saucelabs #665

Open narottamgla opened 7 years ago

narottamgla commented 7 years ago

Able to run selenium test scripts with browser mob proxy successfully and .HAR is getting generated in my local system. But when running same script with sauce labs, application pages are not able to open. Kindly suggest some solution. It will be great if provide some demo code. Thanks

saurabh0891 commented 7 years ago

Are you using java or C# because I am trying to capture Har in C# with selenium but I am only able to capture, "log":{"version":"1.2","creator":{"name":"BrowserMob Proxy","version":"2.1.0-beta-1-legacy","comment":""},"pages":[{"id":"Page 0","startedDateTime":"2017-07-17T14:35:13.306-04:00","title":"Page 0","pageTimings":{"comment":""},"comment":""}],"entries":[],"comment":""}}.

Can you help me with this?

Thanks

ksmanoj commented 7 years ago

i too am facing similar issue. https://github.com/lightbody/browsermob-proxy/issues/643. Did you find a way out?

axtens commented 7 years ago

I expect that the solution is to send a PUT request to /proxy/[port]/har with "captureContent=true". This ordinarily defaults to "false". This is discussed in the REST API documentation

saurabh0891 commented 7 years ago

I am making a PUT request, in the debug mode I checked the URL it is http://localhost:80/proxy/8080/har. I am trying to get HAR from HTTPS but for that I have installed CA in the browser. Let me know if something if I am doing something wrong. Code for HAR request. MakeRequest(string.Format("{0}/{1}/har", this.baseUrlProxy, this.port), "PUT", reference);

axtens commented 7 years ago

I would have expected that your url would be http://localhost:8080/proxy/8081/har or something similar. 8080 would be the port that BMP is running on and 8081 would be the proxy through which the har is being populated.

In the code you describe, 'reference' would contain 'captureContent=true'

saurabh0891 commented 7 years ago

Thank you, I was able to capture the HAR file successfully but content has HTTP 401 error because it needs authentication (User name and password), Does anyone know how to authenticate using proxy in C#. Currently I am doing it like this var chromeOptions = new ChromeOptions(); var proxy = new OpenQA.Selenium.Proxy { HttpProxy = this.proxyUrl, SslProxy = this.proxyUrl }; chromeOptions.Proxy = proxy; webDriver = new ChromeDriver(chromeOptions);

narottamgla commented 7 years ago

@saurabh0891 , Could you please write all the steps that are required. it will be really help me. Thanks.

saurabh0891 commented 7 years ago

from what i read you were able to do this locally? I have done the same, have not tried this with sauce labs but. Let me know you want me to explain how I did locally. I will be happy to help

narottamgla commented 7 years ago

i need help on , how we do it with sauce labs? Yes in local, its working for me. Still could you please write steps if you used Rest API approach? Thanks

ksmanoj commented 7 years ago

@narottamgla You can try this https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy+with+an+Additional+Proxy+Setup if "Different Machine, But Same Network"