Can a watir browser object be re-used in a later Ruby process?

后端 未结 5 945
一向
一向 2021-01-14 05:39

So let\'s say pretty often a script runs that opens a browser and does web things:

require \'watir-webdriver\'

$browser = Watir::Browser.new(:firefox, :prof         


        
5条回答
  •  无人共我
    2021-01-14 06:16

    You can use DRb like this:
    browsers pool:

    require 'drb'
    require 'watir'
    
    browser = Watir::Browser.new :chrome
    DRb.start_service 'druby://127.0.0.1:9395', browser
    
    gets
    

    and then from test script use this browser:

    require 'drb'
    browser = DRbObject.new_with_uri 'druby://127.0.0.1:9395'
    browser.goto 'stackoverflow.com'
    

提交回复
热议问题