Sha256: 5f8f2e1b1b87ba3c9f77c436b510af5b224767e29731f2ad9ea056673242ff88

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

require 'capybara/node/element'

class Capybara::Node::ShadowRoot < Capybara::Node::Element
  def host
    evaluate_script("this.host")
  end

  def text(type = nil, normalize_ws: false)
    case base.class.to_s
    when "Capybara::Selenium::SafariNode", "Capybara::Cuprite::Node"
      all("*")
        .select { |node| node.send(:parent).nil? }
        .map { |node| node.text(type, normalize_ws: normalize_ws) }
        .join
    else # For Selenium + Chrome and Selenium + Edge:
      all("*")
        .map { |node| node.text(type, normalize_ws: normalize_ws) }
        .join
    end
  end

  def tag_name
    host.tag_name
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capybara-shadowdom-0.3.0 lib/capybara/node/shadow_root.rb
capybara-shadowdom-0.1.0 lib/capybara/node/shadow_root.rb