browsermob-proxy-py
browsermob-proxy-py copied to clipboard
Firefox not use proxy
I run selenium hub with firefox and proxy browsermob by bwowk/browsermob-proxy
- all in
docker-compose.yml
file
hub:
image: selenium/hub
ports:
- 4444:4444
firefox:
image: selenium/node-firefox
links:
- hub
- proxy
proxy:
image: bwowk/browsermob-proxy
ports:
- 58080:8080
- Create a Dockerfile with
pip install selenium browsermob-proxy
and linkhub
andproxy
FROM python:3-alpine
RUN pip install selenium browsermob-proxy
- in terminal write
from selenium import webdriver
from browsermobproxy import Client
proxyClient = Client("proxy:8080")
proxy = proxyClient.selenium_proxy()
caps = webdriver.DesiredCapabilities.FIREFOX.copy()
proxy.add_to_capabilities(caps)
driver = webdriver.Remote(command_executor='http://hub:4444/wd/hub', desired_capabilities=caps)
proxyClient.new_har()
driver.get('http://google.com')
for ent in proxyClient.har['log']['entries']:
print(ent['request']['url'])
proxyClient.close()
driver.quit()
in debug i see that var caps
have are proxy key and in proxy server i see that new proxy is registered
Result
But firefox does not use this proxy address. That is why i can not get logs.
proxyClient.har['log']['entries']
is null []
in docker image
Hi @Negashev
I too had the same issue and came up with the following work around. The problem is that when you use browsermobproxy (bmp), any https requests go through the MITM with LittleProxy. This uses its own self signed certificate which is not trusted by your browser. So what I did was:
- Created a profile that I can utilize
- Opened up firefox using that profile and added the certificate as an authority by going to: Tools->Options->Advanced->Certificates->View Certificates button. Under Authorities tab, hit Import and find the: ca-certificate-rsa.cer file which can be found in your browsermob directory under ssl-support. Once you install the authority, any secure site you visit using the proxy will be fine.
profile = webdriver.FirefoxProfile(profile_directory=FIREFOX_PROFILE)
profile.set_proxy(self.proxy.selenium_proxy())
profile.accept_untrusted_certs = True
profile.assume_untrusted_cert_issuer = False
profile.update_preferences()
self.browser = webdriver.Firefox(firefox_profile=profile, proxy=self.proxy)
Hope this helps Cheers,
Thusjanthan Kubendranathan
This is not working