From e7e42401c107fbefae9375f9e2ed29648d2912d2 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Sat, 23 May 2020 11:28:24 -0700 Subject: [PATCH] Swallow JS error when attempting to get page source with selenium driver --- lib/capybara/selenium/driver.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/capybara/selenium/driver.rb b/lib/capybara/selenium/driver.rb index 9acb60e9..2cb10d3a 100644 --- a/lib/capybara/selenium/driver.rb +++ b/lib/capybara/selenium/driver.rb @@ -85,6 +85,10 @@ class Capybara::Selenium::Driver < Capybara::Driver::Base def html browser.page_source + rescue Selenium::WebDriver::Error::JavascriptError => e + return '' if e.match?(/documentElement is null/) + + raise end def title