Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox not use proxy #64

Open
Negashev opened this issue Nov 29, 2016 · 2 comments
Open

Firefox not use proxy #64

Negashev opened this issue Nov 29, 2016 · 2 comments

Comments

@Negashev
Copy link

Negashev commented Nov 29, 2016

I run selenium hub with firefox and proxy browsermob by bwowk/browsermob-proxy

  1. 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
  1. Create a Dockerfile with pip install selenium browsermob-proxy and link hub and proxy
FROM python:3-alpine
RUN pip install selenium browsermob-proxy
  1. 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
3
4

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
5

@tkuben
Copy link

tkuben commented Dec 22, 2016

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:

  1. Created a profile that I can utilize
  2. 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

@frogfx
Copy link

frogfx commented Jul 27, 2018

This is not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants