在 ubuntu 系统上,我正在尝试将“browsernmob-proxy”与 python-selenium 测试一起使用。按照此处的文档,我安装了“browsermob-proxy”并尝试了以下 python 代码:
from selenium import webdriver
from browsermobproxy import Server
server = Server("/home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy/server.py")
server.start()
但这立即失败并出现以下错误:
======================================================================
ERROR: test_example2.TestSuite.test_network
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/adietz/Projects/Jenkins/bsp-usecase-tests/selenium/test_example2.py", line 41, in test_network
server.start()
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/browsermobproxy/server.py", line 113, in start
stderr=subprocess.STDOUT)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
知道如何解决这个问题吗?
我也尝试使用
server = Server("/home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy")
相反,但这失败并出现以下错误:
======================================================================
ERROR: test_example2.TestSuite.test_network
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/home/adietz/Projects/Jenkins/bsp-usecase-tests/selenium/test_example2.py", line 40, in test_network
server = Server("/home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy")
File "/home/adietz/Projects/Venv/nosetests/local/lib/python2.7/site-packages/browsermobproxy/server.py", line 81, in __init__
"in path provided: %s" % path)
ProxyServerError: Browsermob-Proxy binary couldn't be found in path provided: /home/adietz/Projects/Venv/nosetests/lib/python2.7/site-packages/browsermobproxy
附录
- 我可能设法
browsermob-proxy
在端口 8088 或 8089 上获得了 tun(不完全确定),但示例代码仍然无法运行......