Skip to content

Commit

Permalink
Merge pull request #2501 from georgeclaghorn/selenium-webdriver-4-new…
Browse files Browse the repository at this point in the history
…-window-deprecation

Shush deprecation warning when opening new window on Selenium WebDriver 4
  • Loading branch information
twalpole authored Oct 23, 2021
2 parents 5e51607 + 44dd1dc commit 554c2ac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/capybara/selenium/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ def window_handles
end

def open_new_window(kind = :tab)
browser.manage.new_window(kind)
if browser.switch_to.respond_to?(:new_window)
browser.switch_to.new_window(kind)
else
browser.manage.new_window(kind)
end
rescue NoMethodError, Selenium::WebDriver::Error::WebDriverError
# If not supported by the driver or browser default to using JS
browser.execute_script('window.open();')
Expand Down

0 comments on commit 554c2ac

Please sign in to comment.