lib/superbot/teleport/cli/root_command.rb in superbot-teleport-0.2.7 vs lib/superbot/teleport/cli/root_command.rb in superbot-teleport-0.2.8

- old
+ new

@@ -14,32 +14,39 @@ end option ['--browser'], 'BROWSER', "Browser type to use. Can be either local or cloud", default: 'cloud' option ['--region'], 'REGION', 'Region for remote webdriver' option ['--org'], 'ORGANIZATION', 'Name of organization to take action', attribute_name: :organization + option ['--reuse'], :flag, "Reuse existing session" def execute validate_teleport_options(browser, organization) run_local_chromedriver if browser == 'local' puts 'Opening teleport...', '' puts 'Configure your remote webdriver to http://localhost:4567/wd/hub', '' puts 'Press [control+c] to exit', '' - @web = Superbot::Web.run!(webdriver_type: browser, region: region, organization: organization) - ensure - close_teleport - end + @web = Superbot::Web.run!( + webdriver_type: browser, + region: region, + organization: organization, + reuse: reuse? + ) - def close_teleport - @web&.quit! - @chromedriver&.kill + at_exit do + @web&.quit! + end end def run_local_chromedriver chromedriver_path = Chromedriver::Helper.new.binary_path @chromedriver = Kommando.run_async "#{chromedriver_path} --silent --port=9515 --url-base=wd/hub" + + at_exit do + @chromedriver&.kill + end end end end end end