Class: LdsMenu

Inherits:
Object
  • Object
show all
Defined in:
lib/TNR360/components/lds_menu.rb

Instance Method Summary collapse

Constructor Details

#initialize(browser, menu_item_text) ⇒ LdsMenu

constructor



9
10
11
12
13
# File 'lib/TNR360/components/lds_menu.rb', line 9

def initialize(browser,menu_item_text)
  @browser =browser
  @menu_item_text=menu_item_text
  @exists
end

Instance Method Details

#clickObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/TNR360/components/lds_menu.rb', line 22

def click
  menu_path = @menu_item_text.split('/')
  raise "Provide at least one level of menu item" if (menu_path.length < 1)
  for i in 0..(menu_path.length-1)
    puts "Value of local variable is #{i}"
    case i
      when 0
        @browser.div.li(:id => menu_path[i]).when_present.click
        sleep($small_wait_time)
      when 1
        @browser.div.table(:id=> menu_path[i]).button.when_present.click
        sleep($small_wait_time)
      when i==menu_path.length-1
        @browser.a(:text=>menu_path[i]).when_present.click
        sleep($small_wait_time)
      else
        @browser.a(:text=>menu_path[i]).when_present.hover
        sleep($small_wait_time)
        if i==menu_path.length-1
          @browser.a(:text=>menu_path[i]).when_present.click
        end
    end
  end
end

#to_sObject

print object



15
16
17
18
19
# File 'lib/TNR360/components/lds_menu.rb', line 15

def to_s
  "\n***** Menu *****"+
      "\nMenu item text : "+ bool_no_null(@menu_item_text.to_s)+
      "\n**********"
end