Ruby的browsermob代理gem对其他人不起作用吗?

Ruby的browsermob代理gem对其他人不起作用吗?,ruby,selenium,proxy,selenium-webdriver,Ruby,Selenium,Proxy,Selenium Webdriver,我一直在尝试实现Browsermob Proxy来检测网络流量,我正在尝试实现自动化,我已经将Github存储库中的示例代码复制到我自己的代码中,但终端告诉我Proxy.har(har部分)是一个未定义的方法。进一步检查后,proxy.rb文件几乎完全为空,没有任何定义的方法或构造函数 以下是github回购协议: 谁能告诉我这里发生了什么事 Before ('@selenium_firefox_networkproxy') do @server = BrowserMob::Proxy::Se

我一直在尝试实现Browsermob Proxy来检测网络流量,我正在尝试实现自动化,我已经将Github存储库中的示例代码复制到我自己的代码中,但终端告诉我Proxy.har(har部分)是一个未定义的方法。进一步检查后,proxy.rb文件几乎完全为空,没有任何定义的方法或构造函数

以下是github回购协议:

谁能告诉我这里发生了什么事

Before ('@selenium_firefox_networkproxy') do
@server = BrowserMob::Proxy::Server.new("/Users/eliotchan/.rvm/gems/ruby-1.9.2-p320@cucumber/gems/browsermob-proxy-0.0.9/lib/browsermob-proxy.rb")
@server.start

@proxy = server.create_proxy

@profile = Selenium::WebDriver::Firefox::Profile.new
@profile.proxy = proxy.selenium_proxy

@driver = Selenium::WebDriver.for(
:remote,
:url => "http://"+FIREFOX_IP+"/wd/hub",
:desired_capabilities => :firefox,
:profile => @profile)

@proxy.new_har "Analytics"

@driver.manage.timeouts.implicit_wait = 30

@verification_errors = []
end

After ('@selenium_firefox_networkproxy') do
@harfile = @proxy.har
@har.save_to "/Users/eliotchan/Documents/Analytics.har"
@proxy.close
@driver.quit
@verification_errors.should == []
end

我得到的错误是nil:NilClass(NoMethodError)的未定义方法“har”

听起来像是语法问题,但请发布您遇到问题的实际代码以及运行时遇到的特定错误。@ZachKemp添加了代码,error是与行
@harfile=@proxy.har
相关的错误吗?你的
前/后(…)语法从何而来?@ZachKemp是的,它是。Before/After用于标记,我将其放入.feature文件中,以便为每个步骤加载某些内容。它们在一个.env文件中。好的,这可能是一个黄瓜问题。症状是
@proxy
变量不是持久变量。你能试着用一个
块来代替它们吗?将
之前的
替换为
周围的
,在do之后添加
| |,block
,插入
block。在
之后调用
之前的
并删除
之后的
行。