Class: Selenium::WebDriver::Elements::Textbox

Inherits:
Element
  • Object
show all
Defined in:
lib/selenium/webdriver/elements/textbox.rb

Instance Method Summary collapse

Methods inherited from Element

#create_element, #element_present?, #find_element, #find_elements, #method_missing

Constructor Details

#initialize(element, browser) ⇒ Textbox

Returns a new instance of Textbox.



9
10
11
12
13
14
# File 'lib/selenium/webdriver/elements/textbox.rb', line 9

def initialize element, browser
  super element, browser
  unless element.tag_name == 'input' or element.tag_name == 'textarea'
    raise TypeError.new "Can't create Textbox decorator for #{element.inspect}"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Selenium::WebDriver::Elements::Element

Instance Method Details

#append(*args) ⇒ Object



24
25
26
27
28
29
# File 'lib/selenium/webdriver/elements/textbox.rb', line 24

def append *args
  if @browser.browser == :chrome
    @element.click
  end
  @element.send_keys *args
end

#populate(data) ⇒ Object



31
32
33
34
35
# File 'lib/selenium/webdriver/elements/textbox.rb', line 31

def populate data
  if data != nil
    type data
  end
end

#type(*args) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/selenium/webdriver/elements/textbox.rb', line 16

def type *args
  if @browser.browser == :chrome
    @element.click
  end
  @element.clear
  @element.send_keys *args
end