Class: Nobbie::Wx::ElementPathBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/nobbie/wx/impl/element/element_path_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ElementPathBuilder

Returns a new instance of ElementPathBuilder.



11
12
13
# File 'lib/nobbie/wx/impl/element/element_path_builder.rb', line 11

def initialize(name)
  @name = name
end

Instance Method Details

#find_componentObject

Finds the component specified in the path. This implementation is about as dumb as its gets, but does handle named components and menus.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nobbie/wx/impl/element/element_path_builder.rb', line 17

def find_component
  #todo: make me properly navigate component tree
  #todo: I should blow up if multiple windows with the same name are found ....

  #todo: shouldn''t need to pass AUT.gtw here ... nil should search all 
  component = Window.find_window_by_name(@name, APPLICATION_UNDER_TEST.get_top_window)
  return component unless component.nil?

  menu_bar = APPLICATION_UNDER_TEST.get_top_window.get_menu_bar
  unless menu_bar.nil?
    component = menu_bar.get_menu(menu_bar.find_menu(@name))
  end

  #todo: pull this up ...
  Kernel.raise(ComponentNotFoundException, "cannot find component with name: #{to_s}") if component.nil?
  
  component
end

#to_sObject



36
37
38
# File 'lib/nobbie/wx/impl/element/element_path_builder.rb', line 36

def to_s
  "'#{@name}'"
end