2

I am trying to use BrowserMob Proxy with browsermob-proxy-py on Python. I need to capture URLs of all requests from the page. But I can't find https requests in the HAR file. Selenium and BrowserMob Proxy are running on remote machine.

Example code:

from selenium import webdriver
import browsermobproxy

SELENIUM_EXECUTOR = 'http://<remote_ip>:4444/wd/hub'
SELENIUM_DESIRED_CAPABILITIES = {
        'browserName': 'firefox',
        'version': '20.0.0',
        'javascriptEnabled': True,
}

prox = browsermobproxy.Client('<remote_ip>:8080')
driver = webdriver.Remote(
    command_executor=SELENIUM_EXECUTOR,
    desired_capabilities=SELENIUM_DESIRED_CAPABILITIES,
    proxy=prox)

url_to_get = 'http://google.ru'
prox.new_har()
driver.get(url_to_get)
for ent in prox.har['log']['entries']:
    print ent['request']['url']

driver.quit()
prox.close()

This example returns 5 http requests.

But if I change url_to_get to 'https://...', I will see only 3 http requests, and none https requests

Does anyone know how to catch https headers too?

1 Answer 1

2

I can't speak to the python piece, but in our java/junit selenium tests, I had to specify both an http and and https proxy for selenium.

I believe the newest (2.39) version of selenium, they've deprecated specifying an https proxy, instead the parameter specifies an ssl proxy.

Our (java) code looks something like this when we spin up the browser (you'll have to poke around to find the equivalent python - sorry!):

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
//Proxy is from the namespace org.openqa.selenium
Proxy proxy = new Proxy();
//10.0.53.132 == our browsermob proxy server
proxy.setHttpProxy("10.0.53.132:8888");
proxy.setSslProxy("10.0.53.132:8888");
capabilities.setCapability(CapabilityType.PROXY,proxy);
this.driverCapabilities = capabilities;
Sign up to request clarification or add additional context in comments.

3 Comments

Is browsermob server on the same host as the tested website?
That was an awfully long time ago...! :) But no, the browserMob proxy was not running from the app server. And Selenium has had a few revision since then. So your mileage may vary.
I just try to understand if proxy server could turn round https by installing on the same server and by attaching it on https (with help of nginx using information about certification keys).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.