Skip to content

Commit

Permalink
Fix: Chromedriver instances remained active
Browse files Browse the repository at this point in the history
  • Loading branch information
onli committed Jan 10, 2024
1 parent 5c1d877 commit efe2b16
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ def get(url, js = false)

def _get(url, js)
if js
session = Capybara::Session.new(:selenium_chrome_headless)
session.visit(url)
result = session.body
session.driver.browser.close
begin
session = Capybara::Session.new(:selenium_chrome_headless)
session.visit(url)
return session.body
ensure
session.driver.quit
end
else
begin
response = HTTParty.get(url)
Expand Down

0 comments on commit efe2b16

Please sign in to comment.