Class: RIESS::InternetExplorer

Inherits:
Object
  • Object
show all
Defined in:
lib/riess.rb,
lib/checks.rb,
lib/actions.rb,
lib/helpers.rb

Constant Summary collapse

MAX_ELEMENT_FIND_TIME =
1

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ InternetExplorer

Returns a new instance of InternetExplorer.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/riess.rb', line 43

def initialize(config = {})
  @reporter = TestReporter.new
  config = default_riess_config.merge(config)
  
  if config[:attach]
    window_title = config[:title]
    window = ActiveConsole.new(window_title)
    if window.windows[0]
     @ie = window.windows.first.win_object
    else
      puts "Could not find a window to attach to using #{window_title}"
      puts "The following windows were found:"
      window.list_all_windows
    end
  else
     @ie = WIN32OLE.new('InternetExplorer.Application')
  end
  
  @ie.visible = config[:ie_visible] if @ie
 
  if config[:debug]
    Log.level = Log4r::DEBUG 
  end
  
  if config[:reporting]
    @reporter.immediate_feedback = true
    define_finalizer(InternetExplorer, proc {|id| @reporter.execute }) 
  end
end

Instance Method Details

#click(params) ⇒ Object



29
30
31
# File 'lib/actions.rb', line 29

def click(params)
  html_object(params,:click).click
end

#closeObject



9
10
11
# File 'lib/actions.rb', line 9

def close
  @ie.quit
end

#default_riess_configObject



34
35
36
37
38
39
40
41
# File 'lib/riess.rb', line 34

def default_riess_config  
  {
    :reporting => true,
    :debug => false,
    :ie_visible => true,
    :attach => false
  }
end

#enterText(params) ⇒ Object



13
14
15
# File 'lib/actions.rb', line 13

def enterText(params)
  html_object(params,:enterText).set_text
end

#enterTextValue(params) ⇒ Object



17
18
19
# File 'lib/actions.rb', line 17

def enterTextValue(params)
  html_object(params,:enterTextValue).set_text_value
end

#fireEvent(params) ⇒ Object



41
42
43
# File 'lib/actions.rb', line 41

def fireEvent(params)
  html_object(params,:fireEvent).fire_event
end

#html_object(params, method) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/helpers.rb', line 56

def html_object(params,method)
  Log.debug "interface.command\nCommand: #{method} \nParameters: #{params.inspect}\n"
  element_find_time_start = Time.now
  parameter = Parameter.new(params)

  element = nil
  while element.nil? && element_find_time_start + MAX_ELEMENT_FIND_TIME > Time.now      
      element = ElementFinder.new(@ie, parameter).find_element
  end

  if element.nil?
    handle_reporting_if_element_nil(method,parameter) 
    Missing.new(set_return_value(method))
  else
    html_object_factory = HTMLObjectFactory.new(@ie,element,parameter,@reporter)
    html_object_factory.get_object
  end
  
end

#open(url) ⇒ Object



5
6
7
# File 'lib/actions.rb', line 5

def open(url)
  @ie.navigate url
end

#selectMultipleOptions(params) ⇒ Object



25
26
27
# File 'lib/actions.rb', line 25

def selectMultipleOptions(params)
  html_object(params,:selectMultipleOptions).set_multiple_options
end

#selectOption(params) ⇒ Object



21
22
23
# File 'lib/actions.rb', line 21

def selectOption(params)
  html_object(params,:selectOption).set_text_value
end

#simulateKeyPress(params) ⇒ Object



33
34
35
# File 'lib/actions.rb', line 33

def simulateKeyPress(params)
  html_object(params,:simulateKeyPress).simulate_key_press
end

#submitForm(params) ⇒ Object



37
38
39
# File 'lib/actions.rb', line 37

def submitForm(params)
  html_object(params,:submitForm).submit_form
end

#verifyElementChecked(params) ⇒ Object



17
18
19
# File 'lib/checks.rb', line 17

def verifyElementChecked(params)
  html_object(params,:verifyElementChecked).verify_element_checked
end

#verifyElementHtml(params) ⇒ Object



9
10
11
# File 'lib/checks.rb', line 9

def verifyElementHtml(params)
  html_object(params, :verifyElementHtml).verify_element_inner_html
end

#verifyElementNotChecked(params) ⇒ Object



21
22
23
# File 'lib/checks.rb', line 21

def verifyElementNotChecked(params)
  html_object(params,:verifyElementNotChecked).verify_element_not_checked
end

#verifyElementNotPresent(params) ⇒ Object



33
34
35
# File 'lib/checks.rb', line 33

def verifyElementNotPresent(params)
  html_object(params,:verifyElementNotPresent).verify_element_not_present
end

#verifyElementPresent(params) ⇒ Object



29
30
31
# File 'lib/checks.rb', line 29

def verifyElementPresent(params)
  html_object(params,:verifyElementPresent).verify_element_present
end

#verifyElementSource(params) ⇒ Object



25
26
27
# File 'lib/checks.rb', line 25

def verifyElementSource(params)
  html_object(params,:verifyElementSource).verify_element_source
end

#verifyElementText(params) ⇒ Object



5
6
7
# File 'lib/checks.rb', line 5

def verifyElementText(params)
  html_object(params,:verifyElementText).verify_element_inner_text
end

#verifyElementValue(params) ⇒ Object



13
14
15
# File 'lib/checks.rb', line 13

def verifyElementValue(params)
  html_object(params,:verifyElementValue).verify_element_value
end