lib/scrap_kit/recipe.rb in scrap_kit-0.1.8 vs lib/scrap_kit/recipe.rb in scrap_kit-0.1.9

- old
+ new

@@ -25,11 +25,11 @@ end def run output = {} - @browser = Watir::Browser.new(:chrome, headless: true) + @browser = create_browser @browser.goto @url @steps.each do |step| run_step(step) end @@ -189,8 +189,23 @@ sleep 0.25 @browser.wait_until do @browser.ready_state == "complete" end + end + + def create_browser + options = Selenium::WebDriver::Chrome::Options.new + + options.add_argument "--headless" + options.add_argument "--window-size=1080x720" + options.add_argument "--hide-scrollbars" + + if chrome_bin = ENV["GOOGLE_CHROME_SHIM"] + options.add_argument "--no-sandbox" + options.binary = chrome_bin + end + + Watir::Browser.new(:chrome, options: options) end end end