Method: Ferrum::Frame::DOM#css

Defined in:
lib/ferrum/frame/dom.rb

#css(selector, within: nil) ⇒ Array<Node>

Finds nodes by using a CSS path selector.

Examples:

browser.go_to("https://github.com/")
browser.css("a[aria-label='Issues you created']") # => [Node]

Parameters:

  • selector (String)

    The CSS path selector.

  • within (Node, nil) (defaults to: nil)

    The parent node to search within.

Returns:

  • (Array<Node>)

    The matching nodes.



191
192
193
194
195
196
197
198
199
200
# File 'lib/ferrum/frame/dom.rb', line 191

def css(selector, within: nil)
  expr = "    function(selector, within) {\n      within ||= document\n      return Array.from(within.querySelectorAll(selector));\n    }\n  JS\n\n  evaluate_func(expr, selector, within)\nend\n"