Module: TerminusSpec::Platforms::SeleniumWebDriver::WebObject

Defined in:
lib/terminus_spec/platform_selenium/web_objects/all.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



6
7
8
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 6

def ==(other)
  @web_object == other # other.element??
end

#attribute(attribute_name) ⇒ String?

Get the value of a the given attribute of the object.

Parameters:

  • attribute (String)

    name

Returns:

  • (String, nil)

    attribute value



91
92
93
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 91

def attribute(attribute_name)
  @web_object.attribute attribute_name
end

#clearObject



30
31
32
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 30

def clear
  @web_object.clear
end

#exists?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 14

def exists?
  nil != @web_object
end

#right_clickObject



34
35
36
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 34

def right_click
  @web_object.context_click
end

#send_keys(*args) ⇒ Object

Send keystrokes to the object.

Parameters:

  • (String, Symbol, Array)

See Also:

  • Selenium::WebDriver::Keys::KEYS


45
46
47
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 45

def send_keys(*args)
  @web_object.send_keys(*args)
end

#tag_nameObject



26
27
28
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 26

def tag_name
  @web_object.tag_name
end

#textObject



18
19
20
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 18

def text
  @web_object.text
end

#valueObject



22
23
24
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 22

def value
  @web_object.attribute('value')
end

#visible?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 10

def visible?
  @web_object.displayed?
end

#wait_until(timeout = 5, message = nil, &block) ⇒ Object

Waits until a given returns true (and thus was executed).

Parameters:

  • (defaults (Integer)

    to: 5) seconds to wait before timing out

  • the (String)

    message to display if the event times out

  • the

    block to execute when the event occurs



83
84
85
86
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 83

def wait_until(timeout=5, message=nil, &block)
  wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => message})
  wait.until(&block)
end

#when_not_visible(timeout = 5) ⇒ Object

Waits until an object is not visible on the screen.

Parameters:

  • (defaults (Integer)

    to: 5) seconds to wait before timing out



71
72
73
74
75
76
77
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 71

def when_not_visible(timeout=5)
  wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Object not present in #{timeout} seconds"})
  wait.until do
    not self.visible?
  end
  self
end

#when_present(timeout = 5) ⇒ Object

Waits until an object is present on the screen.

Parameters:

  • (defaults (Integer)

    to: 5) seconds to wait before timing out



51
52
53
54
55
56
57
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 51

def when_present(timeout=5)
  wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Object not present in #{timeout} seconds"})
  wait.until do
    self.exists?
  end
  self
end

#when_visible(timeout = 5) ⇒ Object

Waits until an object is visible on the screen.

Parameters:

  • (defaults (Integer)

    to: 5) seconds to wait before timing out



61
62
63
64
65
66
67
# File 'lib/terminus_spec/platform_selenium/web_objects/all.rb', line 61

def when_visible(timeout=5)
  wait = Object::Selenium::WebDriver::Wait.new({:timeout => timeout, :message => "Object not present in #{timeout} seconds"})
  wait.until do
    self.visible?
  end
  self
end