Sha256: 85d1fb17f6d64701374a8b51bbc8a7f2d779d41f2afe97e4038580c984d44a1a

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Watir
  class ShadowRoot
    include Container
    include Exception
    include SearchContext
    include Waitable

    def initialize(element)
      @query_scope = element
    end

    def browser
      @query_scope.browser
    end

    def located?
      !!@shadow_root
    end

    def wd
      assert_exists
      @shadow_root
    end

    def execute_script(script, *args, function_name: nil)
      browser.execute_script(script, *args, function_name: function_name)
    end

    def stale?
      @shadow_root.find_elements(css: 'checking_stale_shadow_root')
      false
    rescue Selenium::WebDriver::Error::DetachedShadowRootError
      true
    end

    def reset!
      @shadow_root = nil
    end

    def locate
      @shadow_root = @query_scope.wd.shadow_root
    rescue Selenium::WebDriver::Error::NoSuchShadowRootError
      nil
    end

    #
    # @api private
    #

    def selector_string
      "#{@query_scope.selector_string} --> shadow_root"
    end

    def custom_message
      ''
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
watir-7.3.0 lib/watir/shadow_root.rb
watir-7.2.2 lib/watir/shadow_root.rb
watir-7.2.1 lib/watir/shadow_root.rb
watir-7.2.0 lib/watir/shadow_root.rb