1

我正在尝试在我的 Selenium 测试中使用 browsermob 代理。因此,我编写了以下代码:

require 'selenium-webdriver'
require 'browsermob/proxy'

server = BrowserMob::Proxy::Server.new 'E:\browsermob\browsermob-proxy-2.0-beta-8'
server.start

但是当我在上面运行脚本时,它会导致ChildProcess::LaunchError

ChildProcess::LaunchError: Unknown error (Windows says "The operation completed successfully.", but it did not.)
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.9/lib/childprocess/windows/process_builder.rb:87:in `create_process'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.9/lib/childprocess/windows/process_builder.rb:34:in `start'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.9/lib/childprocess/windows/process.rb:63:in `launch_process'
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/childprocess-0.3.9/lib/childprocess/abstract_process.rb:72: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 (irb):9
    from C:/Ruby193/bin/irb:12:in `<main>'

请帮我解决这个问题。

4

1 回答 1

0

我遇到了同样的问题,很难从这里的文档中弄清楚,到 browsermob-proxy 服务器的路径也应该包含可执行文件。

在您的情况下,代码应该是下一个:

需要'selenium-webdriver' 需要'browsermob/proxy'

服务器 = BrowserMob::Proxy::Server.new "E:\browsermob\browsermob-proxy-2.0-beta-8\browsermob-proxy" server.start

希望能帮助到你

于 2014-01-13T14:14:55.120 回答