Hey everyone, I really could use some help with this. I posted the problem on StackOverflow a couple of days ago, but have yet to receive any responses/assistance. Pretty much stuck. For the love and adoration of a complete stranger, I implore you for assistance. :)
Goal:
I want to run a Selenium Python script through BrowserMob-Proxy, which will capture and output a HAR file capture.
Problem:
I have a functional (very basic) Python script (shown below). When it
is altered to utilize BrowserMob-Proxy to capture a HAR however, it fails.
Below I provide two different scripts that both fail, but for
differing reasons (details provided before code snippets).
Software Specs:
BrowserMob-Proxy Explanation:
As mentioned before, I am using both 0.6.0 AND 2.0-beta-8. The
reasoning for this is that A) LightBody recently
indicated that his most current release (2.0-beta-9) is not functional
and advises users to use 2.0-beta-8 instead and B) from what I can tell
from reading various site/stackoverflow information is that 0.6.0
(acquired through PIP) is used to make calls to the Client.py/Server.py,
whereas 2.0-beta-8 is used to initiate the Server. To be honest, this
confuses me. When importing BMP's Server however, it requires a batch
(.bat) file to initiate the server, which is not provided in 0.6.0, but
is with 2.0-beta-8...if anyone can shed some light on this area of
confusion (I suspect it is the root of my problems described below),
then I'd be most appreciative.
Selenium Script (this script works):
This script succeeds in running and does not produce any errors. It
is provided for illustrative purposes to indicate it works before adding
BMP logic.
"""This script utilizes Selenium to obtain the Google homepage""" from selenium import webdriver driver = webdriver.Firefox() # Opens FireFox browser. driver.get('https://google.com/') # Gets google.com and loads page in browser. driver.quit() # Closes Firefox browser
Script ALPHA with BMP (does not work):
This code will succeed in running the script and will not produce any
errors. However, when searching the entirety of my hard drive, I never
succeed in locating ALPHA_HAR.har.
"""Using the same functional Selenium script, produce ALPHA_HAR.har output""" from browsermobproxy import Serverserver = Server('C:\Users\Matt\Desktop\\browsermob-proxy-2.0-beta-8\\bin\\browsermob-proxy')server.start()proxy = server.create_proxy()from selenium import webdriverdriver = webdriver.Firefox() # Opens FireFox browser.proxy.new_har("ALPHA_HAR") # Creates a new HARdriver.get("https://www.google.com/") # Gets google.com and loads page in browser.proxy.har # Returns a HAR JSON blobserver.stop()
Script BETA with BMP (does not work):
This code was taken from http://browsermob-proxy-py.readthedocs.org/en/latest/.
When running the below code, FireFox will attempt to get google.com,
but will never succeed in loading the page. Eventually it will time out
without producing any errors. And BETA_HAR.har can't be found anywhere
on my hard drive. I have also noticed that, when trying to use this
browser to visit any other site, it will similarly fail to load (I
suspect this is due to the proxy not being configured properly).
"""Using the same functional Selenium script, produce BETA_HAR.har output"""from browsermobproxy import Serverserver = Server("C:\Users\Matt\Desktop\\browsermob-proxy-2.0-beta-8\\bin\\browsermob-proxy")server.start()proxy = server.create_proxy()from selenium import webdriverprofile = webdriver.FirefoxProfile()profile.set_proxy(proxy.selenium_proxy())driver = webdriver.Firefox(firefox_profile=profile)proxy.new_har("BETA_HAR") # Creates a new HARdriver.get("https://www.google.com/") # Gets google.com and loads page in browser.proxy.har # Returns a HAR JSON blobserver.stop()
--
---
You received this message because you are subscribed to the Google Groups "BrowserMob Proxy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to browsermob-pro...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
from selenium import webdriverprofile = webdriver.FirefoxProfile()profile.set_proxy(proxy.selenium_proxy())driver = webdriver.Firefox(firefox_profile=profile)
...
...</bl