Class: Aranha::Selenium::Session::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/aranha/selenium/session/element.rb

Instance Method Summary collapse

Instance Method Details

#clickBoolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
# File 'lib/aranha/selenium/session/element.rb', line 12

def click
  click!
  true
rescue ::Selenium::WebDriver::Error::ElementClickInterceptedError,
       ::Selenium::WebDriver::Error::ElementNotInteractableError,
       ::Selenium::WebDriver::Error::NoSuchElementError,
       ::Selenium::WebDriver::Error::StaleElementReferenceError
  false
end

#click!self

Returns:

  • (self)

Raises:

  • (Selenium::WebDriver::Error::ElementClickInterceptedError)
  • (Selenium::WebDriver::Error::ElementNotInteractableError)
  • (Selenium::WebDriver::Error::NoSuchElementError)
  • (Selenium::WebDriver::Error::StaleElementReferenceError)


27
28
29
30
31
# File 'lib/aranha/selenium/session/element.rb', line 27

def click!
  find!.click

  self
end

#findSelenium::WebDriver::Element?

Returns:

  • (Selenium::WebDriver::Element, nil)


34
35
36
37
# File 'lib/aranha/selenium/session/element.rb', line 34

def find
  r = session.find_elements(*find_args)
  r.any? ? r.first : nil
end

#find!Selenium::WebDriver::Element

Returns:

  • (Selenium::WebDriver::Element)

Raises:

  • (Selenium::WebDriver::Error::NoSuchElementError)


41
42
43
44
45
46
# File 'lib/aranha/selenium/session/element.rb', line 41

def find!
  return find_args.first if find_args.count >= 1 &&
                            find_args.first.is_a?(::Selenium::WebDriver::Element)

  session.__getobj__.find_element(*find_args)
end

#wait_click(*session_wait_args, &block) ⇒ self

Parameters:

  • session_wait_args (Array)

    Arguments for Aranha::Selenium::Session::Wait.wait.

Returns:

  • (self)


50
51
52
53
54
55
56
# File 'lib/aranha/selenium/session/element.rb', line 50

def wait_click(*session_wait_args, &block)
  session.wait(*session_wait_args).until do
    block.if_present(&:call)
    click
  end
  self
end