Sha256: 6a580bb3def8fb82030dcd11ad516f8ed8761d1dba86845d5473732e3cc3c968

Contents?: true

Size: 1.1 KB

Versions: 26

Compression:

Stored size: 1.1 KB

Contents

require_relative "../webdriver_script_adapter/execute_async_script_adapter"
require_relative "../webdriver_script_adapter/frame_adapter"
require_relative "../webdriver_script_adapter/query_selector_adapter"
require_relative "../loader"
require_relative "./configuration"

module Axe
  class Core
    JS_NAME = "axe"

    def initialize(page)
      @page = wrap_driver page
      load_axe_core Axe::Configuration.instance.jslib
    end

    def call(callable)
      callable.call(@page)
    end

    private

    def load_axe_core(source)
      Common::Loader.new(@page, self).call(source) unless already_loaded?
    end

    def already_loaded?
      @page.evaluate_script <<-JS
        window.#{JS_NAME} &&
        typeof #{JS_NAME}.run === 'function'
      JS
    end

    def wrap_driver(driver)
      ::WebDriverScriptAdapter::QuerySelectorAdapter.wrap(
        ::WebDriverScriptAdapter::FrameAdapter.wrap(
          ::WebDriverScriptAdapter::ExecuteAsyncScriptAdapter.wrap(
            ::WebDriverScriptAdapter::ExecEvalScriptAdapter.wrap(
              driver
            )
          )
        )
      )
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
axe-core-api-4.0.0.pre.eafff01 lib/axe/core.rb
axe-core-api-4.0.0.pre.2bf4a90 lib/axe/core.rb
axe-core-api-4.0.0.pre.c36a2a1 lib/axe/core.rb
axe-core-api-4.0.0.pre.1dd5198 lib/axe/core.rb
axe-core-api-4.0.0.pre.88457a3 lib/axe/core.rb
axe-core-api-4.0.0.pre.f26d625 lib/axe/core.rb
axe-core-api-4.0.0.pre.3039ae4 lib/axe/core.rb
axe-core-api-4.0.0.pre.2b814f9 lib/axe/core.rb
axe-core-api-4.0.0.pre.6784dc7 lib/axe/core.rb
axe-core-api-4.1.0 lib/axe/core.rb
axe-core-api-4.0.0.pre.e73e472 lib/axe/core.rb
axe-core-api-4.0.0.pre.588d434 lib/axe/core.rb
axe-core-api-4.0.0.pre.287120d lib/axe/core.rb
axe-core-api-4.0.0.pre.7ce7a3d lib/axe/core.rb
axe-core-api-4.0.0.pre.41da1f0 lib/axe/core.rb
axe-core-api-4.0.0.pre.9f8d35d lib/axe/core.rb
axe-core-api-4.0.0.pre.5b79e45 lib/axe/core.rb
axe-core-api-4.0.0.pre.04a92d1 lib/axe/core.rb
axe-core-api-4.0.0.pre.4913ee6 lib/axe/core.rb
axe-core-api-4.0.0 lib/axe/core.rb