Class: LessForm::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/less-form/element.rb

Direct Known Subclasses

Button, Option, Radio, Select, Table, TextField

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wd_element) ⇒ Element

Returns a new instance of Element.



4
5
6
# File 'lib/less-form/element.rb', line 4

def initialize wd_element
	@element = wd_element		
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &blk) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/less-form/element.rb', line 32

def method_missing m, *args, &blk
	if @element.respond_to?(m)
		@element.send m, *args, &blk
	else
		value = @element.attribute(m.to_s)
		(value.nil?)? super : value
	end #if
end

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element.



3
4
5
# File 'lib/less-form/element.rb', line 3

def element
  @element
end

Instance Method Details

#clickObject



16
17
18
# File 'lib/less-form/element.rb', line 16

def click
	@element.click
end

#displayed?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/less-form/element.rb', line 24

def displayed?
	@element.displayed?
end

#flashObject



28
29
30
# File 'lib/less-form/element.rb', line 28

def flash
	@element.flash
end

#set(what = nil) ⇒ Object



12
13
14
# File 'lib/less-form/element.rb', line 12

def set what=nil
	@element.send_keys(what)
end

#textObject



20
21
22
# File 'lib/less-form/element.rb', line 20

def text
	@element.text
end

#valid_element?(wd_element) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



8
9
10
# File 'lib/less-form/element.rb', line 8

def valid_element? wd_element
	raise InvalidWebDriverElementError unless wd_element.is_a?(Selenium::WebDriver::Element)
end