Issue
I have written following code in python to work with BrowserMob-proxy. Have the same library added and I can see it in site packages.
from selenium import webdriver
from browsermobproxy import Server
server = Server("browsermob-proxy-2.1.4/bin/browsermob-proxy")
server.start()
proxy = self.server.create_proxy()
driver = webdriver.Chrome
driver = webdriver.Chrome(executable_path="/Users/user/Downloads/chromedriver")
proxy.new_har("google")
proxy.har # returns a HAR JSON blob
driver.get("http://www.python.org")
server.stop()
driver.quit()
driver.close()
Getting below error and in log file I see operation is not permitted. I have seen many available resources online but no sure if anything to be set in addition to other.Note: I am using Mac ..Anything to be done here ?
Seeing this in eclipse console: Browsermobproxy.exceptions.ProxyServerError: The Browsermob-Proxy server process failed to start. Check <_io.TextIOWrapper name='/..workspace/server.log' mode='w' encoding='UTF-8'>for a helpful error message.
Solution
Looks like , the server was not running and start up failed due to some error. Got it working with setting the proxy before we call driver.get
server = Server(path)
server.start()
proxy = server.create_proxy()
options = webdriver.ChromeOptions()
options.add_argument("--proxy-server={}".format(proxy.proxy))
options.add_argument('ignore-certificate-errors')
driver =webdriver.Chrome("/Users/username/Downloads/chromedriver",options=options)
proxy.new_har("google")
driver.get(url)
time.sleep(5)
Answered By - Sriram S
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.