WATIR保存并加载对象

时间:2018-02-13 12:41:41

标签: ruby yaml selenium-chromedriver watir

browser = Watir::Browser.new :chrome
browser = Watir::Browser.start @url = query

yml = YAML.dump(browser)
File.open("watir.obj", 'w') { |file| file.write(yml) }

#object saved ok!

#BUT PROBLEM HERE 
pp browser = YAML::load_file("watir.obj")
puts browser.html


pp will return #<Watir::Browser:0x32ef165a7e2a48ce closed=true> <<< CLOSED

如果我尝试第二部分脚本 - 我会收到错误:

/Users/lir/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:906:in `rescue in block in connect': Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515) (Errno::ECONNREFUSED)

看起来好像无法连接到chromedriver。是

0 个答案:

没有答案