我正在尝试在Selenium测试中使用browsermob代理。因此我写了以下代码:
require 'selenium-webdriver'
require 'browsermob/proxy'
server = BrowserMob::Proxy::Server.new ".//browsermob-proxy-2.0-beta-8//"
server.start
但是当我在脚本上面运行时,会导致Access is denied. (5) (ChildProcess::LaunchError)
错误:
c:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.6/lib/childprocess/windows/process_builder.rb:87:in `create_process': Access is denied. (5) (ChildProcess::LaunchError)
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.6/lib/childprocess/windows/process_builder.rb:34:in `start'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.6/lib/childprocess/windows/process.rb:63:in `launch_process'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.6/lib/childprocess/abstract_process.rb:67:in `start'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/browsermob-proxy-0.1.3/lib/browsermob/proxy/server.rb:27:in `start'
from test.rb:6:in `<main>'
请帮我摆脱错误。
答案 0 :(得分:0)
我遇到了同样的问题,很难从文档here中弄明白,浏览器代理服务器的路径也应该包含可执行文件。
在您的情况下,代码应该是下一个:
require 'selenium-webdriver'
require 'browsermob/proxy'
server = BrowserMob::Proxy::Server.new ".//browsermob-proxy-2.0-beta-8//bin//browsermob-proxy.bat"
server.start
希望有所帮助