require 'forwardable'
require 'axe/page/web_driver_to_capybara_page_adapter'
require 'axe/page/execute_async_script_adapter'

module Axe
  class Page
    extend Forwardable
    def_delegators :@browser, :evaluate_script, :execute_script, :execute_async_script

    def initialize(browser)
      @browser = browser
      adapt_webdriver_to_capybara
      adapt_async_script_executor
    end

    private

    def adapt_webdriver_to_capybara
      extend WebDriverToCapybaraPageAdapter unless @browser.respond_to? :evaluate_script
    end

    def adapt_async_script_executor
      extend ExecuteAsyncScriptAdapter unless @browser.respond_to? :execute_async_script
    end
  end
end

require 'forwardable'
require 'axe/page/web_driver_to_capybara_page_adapter'
require 'axe/page/execute_async_script_adapter'

module Axe
  class Page
    extend Forwardable
    def_delegators :@browser, :evaluate_script, :execute_script

    def initialize(browser)
      @browser = browser
      adapt_webdriver_to_capybara
      adapt_async_script_executor
    end

    private

    def adapt_webdriver_to_capybara
      extend WebDriverToCapybaraPageAdapter unless @browser.respond_to? :evaluate_script
    end

    def adapt_async_script_executor
      extend ExecuteAsyncScriptAdapter
    end
  end
end

Revert "Only adapt if driver doesn't already support async script"
Revert "Only adapt if driver doesn't already support async script"

This reverts commit 3c5f0d8544133e74304f9697a53a995ba120046f.
