Module: PageObject::Accessors

Defined in:
lib/sakai-oae-test-api/gem_extensions.rb

Instance Method Summary collapse

Instance Method Details

#float_menu(name, menu_text, link_text, target_class) ⇒ Object

Use this for menus that require floating the mouse over the first link, before you click on the second link…



29
30
31
32
33
34
35
36
37
# File 'lib/sakai-oae-test-api/gem_extensions.rb', line 29

def float_menu(name, menu_text, link_text, target_class)   
  define_method(name) {
    self.back_to_top
    self.link(:text=>menu_text).fire_event("onmouseover")
    self.link(:text=>/#{link_text}/).click
    self.linger_for_ajax(10)
    eval(target_class).new @browser
  }
end

#insert_button(name, id, module_name = nil) ⇒ Object

This method is specifically for defining the contents of the Insert button, found on the Document Edit page. See the module DocumentWidget



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/sakai-oae-test-api/gem_extensions.rb', line 94

def insert_button(name, id, module_name=nil)
  define_method("insert_#{name}") {
    self.button(:id=>"sakaidocs_insert_dropdown_button").click
    sleep 0.1
    self.button(:id=>id).click
    unless module_name==nil
      self.class.class_eval { include eval(module_name) }
      sleep 0.4
    end
    self.wait_for_ajax(2)
  }
end

Use this for button objects that cause page navigations and thus require a new Page Object.



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/sakai-oae-test-api/gem_extensions.rb', line 67

def navigating_button(name, id, class_name=nil)
  define_method(name) { 
      self.button(:id=>id).click
      sleep 0.2
      browser.wait_for_ajax(2)
      sleep 0.2
      unless class_name==nil
        eval(class_name).new @browser
      end
    }
end

Use this for links on the page that cause page navigations and thus require a new Page Object.



81
82
83
84
85
86
87
88
89
# File 'lib/sakai-oae-test-api/gem_extensions.rb', line 81

def navigating_link(name, link_text, class_name=nil)
  define_method(name) { 
    self.link(:text=>/#{Regexp.escape(link_text)}/).click
    sleep 2 # wait_for_ajax keeps throwing unknown JS errors in Selenium-webdriver
    unless class_name==nil
      eval(class_name).new @browser
    end
  }
end


39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sakai-oae-test-api/gem_extensions.rb', line 39

def open_link(name, klass)
  define_method("open_#{name}") do |value|
    self.back_to_top
    self.link(:text=>/#{value}/).click
    sleep 2
    self.linger_for_ajax(6)
    # This code is necessary because of a null style tag
    # that confuses Watir into thinking the buttons aren't really there.
    if self.div(:id=>"joinrequestbuttons_widget").exist?
      @browser.execute_script("$('#joinrequestbuttons_widget').css({display: 'block'})")
    end
    eval(klass).new @browser
  end
end

#permissions_menu(name, text) ⇒ Object

Use this for menu items that are accessed via clicking the div to get to the target menu item.



56
57
58
59
60
61
62
63
# File 'lib/sakai-oae-test-api/gem_extensions.rb', line 56

def permissions_menu(name, text) #, target_class)
  define_method(name) {
    self.link(:text=>text).fire_event("onmouseover")
    self.link(:text=>text).parent.div(:class=>"lhnavigation_selected_submenu_image").fire_event("onclick")
    self.link(:id=>"lhnavigation_submenu_user_permissions").click
    self.class.class_eval { include ProfilePermissionsPopUp }
  }
end