Module: CapybaraAngularHelpers
- Defined in:
- lib/capybara_angular_helpers.rb,
lib/capybara_angular_helpers/version.rb
Constant Summary collapse
- VERSION =
"0.1.3"
Instance Method Summary collapse
- #ng_click_on(target, opts = {}) ⇒ Object
- #ng_fill_in(target, opts) ⇒ Object
- #ng_ionic_click_left_nav ⇒ Object
- #ng_ionic_click_right_nav ⇒ Object
- #ng_ionic_list_item_click_on(list_item_text, button_text = nil) ⇒ Object
- #ng_toggle(target) ⇒ Object
Instance Method Details
#ng_click_on(target, opts = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/capybara_angular_helpers.rb', line 41 def ng_click_on(target, opts = {}) selector = [ '*[ui-sref]', '*[ng-click]', '*[menu-toggle]', '.tab-item', 'button', ].join(',') if element_index = opts[:index] target_element = all(selector, text: target)[element_index] if !target_element raise "#{target} could not be found" end else target_element = find(:css, selector, text: target) end target_element.click end |
#ng_fill_in(target, opts) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/capybara_angular_helpers.rb', line 5 def ng_fill_in(target, opts) if opts.is_a?(Fixnum) opts = opts.to_s end if opts.is_a?(String) || opts.is_a?(TrueClass) || opts.is_a?(FalseClass) opts = { with: opts } end selector = [ "input[ng-model='#{target}']", "textarea[ng-model='#{target}']", "select[ng-model='#{target}']", ].join(',') if element_index = opts[:index] target_element = all(selector)[element_index] if !target_element raise "#{target} could not be found" end else target_element = find(:css, selector) end if target_element.tag_name == 'select' target_element.find(:option, opts[:with]).select_option else target_element.set(opts[:with]) end end |
#ng_ionic_click_left_nav ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/capybara_angular_helpers.rb', line 63 def ng_ionic_click_left_nav = begin find('ion-header-bar .buttons-left button') rescue Capybara::ElementNotFound find('ion-header-bar .back-button') end .click end |
#ng_ionic_click_right_nav ⇒ Object
73 74 75 |
# File 'lib/capybara_angular_helpers.rb', line 73 def ng_ionic_click_right_nav find('ion-header-bar .buttons-right button').click end |
#ng_ionic_list_item_click_on(list_item_text, button_text = nil) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/capybara_angular_helpers.rb', line 77 def ng_ionic_list_item_click_on(list_item_text, = nil) if .nil? # find(:xpath, "//ion-side-menu-content/descendant::ion-item/descendant-or-self::*[contains(text(), '#{target}')]/ancestor-or-self::ion-item").click find(:xpath, "//ion-side-menu-content/descendant::ion-item/descendant-or-self::*[text()[contains(., '#{list_item_text}')]]/ancestor-or-self::ion-item").click else find(:xpath, "//ion-side-menu-content/descendant::ion-item/descendant-or-self::*[text()[contains(., '#{list_item_text}')]]/ancestor-or-self::ion-item/descendant-or-self::*[text()[contains(., '#{}')]]").click end end |
#ng_toggle(target) ⇒ Object
37 38 39 |
# File 'lib/capybara_angular_helpers.rb', line 37 def ng_toggle(target) find(:css, "div[ng-model='#{target}'] .toggle").click end |