I am trying to use proxpy to monitor any requests made during a python-selenium test. The python code I use is as follows:
from selenium import webdriver
PROXY = "0.0.0.0:9999"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy":PROXY,
"ftpProxy":PROXY,
"sslProxy":PROXY,
"proxyType":"MANUAL"
}
driver = webdriver.Firefox()
driver.get("http://www.google.co.in")
driver.quit()
and I start the proxy as follows:
python proxpy/proxpy/proxpy.py -p 9999
When I run the python test script I get the following error:
Exception happened during processing of request from ('127.0.0.1', 64667)
Traceback (most recent call last):
File "/Users/adietz/anaconda/lib/python2.7/SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "/Users/adietz/anaconda/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Users/adietz/Projects/Invest/browsermob/proxpy/proxpy/core.py", line 56, in __init__
SocketServer.StreamRequestHandler.__init__(self, request, client_address, server)
File "/Users/adietz/anaconda/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/Users/adietz/Projects/Invest/browsermob/proxpy/proxpy/core.py", line 137, in handle
res = self.doCONNECT(host, port, req)
File "/Users/adietz/Projects/Invest/browsermob/proxpy/proxpy/core.py", line 188, in doCONNECT
ssl_version = ssl.PROTOCOL_SSLv23, do_handshake_on_connect = False)
File "/Users/adietz/anaconda/lib/python2.7/ssl.py", line 933, in wrap_socket
ciphers=ciphers)
File "/Users/adietz/anaconda/lib/python2.7/ssl.py", line 544, in __init__
self._context.load_cert_chain(certfile, keyfile)
IOError: [Errno 2] No such file or directory
How can I fix this? How can I avoid this error? How am I able to just monitor the requests and responses...?
On a Linux machine the error is equivalent:
Exception happened during processing of request from ('127.0.0.1', 35348)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/home/adietz/Projects/Invest/browsermob-proxy/proxpy/proxpy/core.py", line 56, in __init__
SocketServer.StreamRequestHandler.__init__(self, request, client_address, server)
File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
self.handle()
File "/home/adietz/Projects/Invest/browsermob-proxy/proxpy/proxpy/core.py", line 137, in handle
res = self.doCONNECT(host, port, req)
File "/home/adietz/Projects/Invest/browsermob-proxy/proxpy/proxpy/core.py", line 188, in doCONNECT
ssl_version = ssl.PROTOCOL_SSLv23, do_handshake_on_connect = False)
File "/usr/lib/python2.7/ssl.py", line 933, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 544, in __init__
self._context.load_cert_chain(certfile, keyfile)
IOError: [Errno 2] No such file or directory
This looks like a problem with proxpy itself. I checked the Github page and the last update is from four years ago. If you are able to switch proxies I would suggest using Browsermob, it's very user friendly. Since you are using python I found a wrapper library from a famous Selenium contributer: https://github.com/AutomatedTester/browsermob-proxy-py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With