File: document.rb

package info (click to toggle)
ruby-capybara 3.40.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,368 kB
  • sloc: ruby: 23,988; javascript: 752; makefile: 11
file content (48 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true

module Capybara
  module Node
    ##
    #
    # A {Capybara::Document} represents an HTML document. Any operation
    # performed on it will be performed on the entire document.
    #
    # @see Capybara::Node
    #
    class Document < Base
      include Capybara::Node::DocumentMatchers

      def inspect
        %(#<Capybara::Document>)
      end

      ##
      #
      # @return [String]    The text of the document
      #
      def text(type = nil, normalize_ws: false)
        find(:xpath, '/html').text(type, normalize_ws: normalize_ws)
      end

      ##
      #
      # @return [String]    The title of the document
      #
      def title
        session.driver.title
      end

      def execute_script(*args)
        find(:xpath, '/html').execute_script(*args)
      end

      def evaluate_script(*args)
        find(:xpath, '/html').evaluate_script(*args)
      end

      def scroll_to(*args, quirks: false, **options)
        find(:xpath, quirks ? '//body' : '/html').scroll_to(*args, **options)
      end
    end
  end
end