Module: Actions
- Included in:
- PineappleTranslator
- Defined in:
- lib/pineapple/actions/check.rb,
lib/pineapple/actions/visit.rb,
lib/pineapple/actions/choose.rb,
lib/pineapple/actions/script.rb,
lib/pineapple/actions/select.rb,
lib/pineapple/actions/fill_in.rb,
lib/pineapple/actions/uncheck.rb,
lib/pineapple/actions/click_on.rb,
lib/pineapple/actions/click_link.rb,
lib/pineapple/actions/click_button.rb,
lib/pineapple/utils/global_selector.rb
Instance Method Summary collapse
- #check(selector) ⇒ Object
- #choose(selector) ⇒ Object
- #click_button(selector) ⇒ Object
- #click_link(selector) ⇒ Object
- #click_on(selector) ⇒ Object
- #fill_in(selector, option) ⇒ Object
- #find_item(selector) ⇒ Object
- #jscript(body) ⇒ Object
- #select(value, option) ⇒ Object
- #uncheck(selector) ⇒ Object
- #visit(url) ⇒ Object
Instance Method Details
#check(selector) ⇒ Object
2 3 4 5 |
# File 'lib/pineapple/actions/check.rb', line 2 def check selector find_item selector jscript "pineappleVars.item.attr('checked', true);" end |
#choose(selector) ⇒ Object
2 3 4 5 |
# File 'lib/pineapple/actions/choose.rb', line 2 def choose selector find_item selector jscript "pineappleVars.item.click();" end |
#click_button(selector) ⇒ Object
2 3 4 5 |
# File 'lib/pineapple/actions/click_button.rb', line 2 def selector find_item selector jscript "pineappleVars.item.trigger('click');" end |
#click_link(selector) ⇒ Object
2 3 4 5 |
# File 'lib/pineapple/actions/click_link.rb', line 2 def click_link selector find_item selector jscript "clickLink(pineappleVars.item[pineappleVars.item.size()-1]);" end |
#click_on(selector) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/pineapple/actions/click_on.rb', line 2 def click_on selector find_item selector @script += <<SCRIPT if (pineappleVars.item.is('a') ) { clickLink(pineappleVars.item[pineappleVars.item.size()-1]); }else{ pineappleVars.item.trigger('click'); } SCRIPT end |
#fill_in(selector, option) ⇒ Object
2 3 4 5 6 |
# File 'lib/pineapple/actions/fill_in.rb', line 2 def fill_in selector, option value = option[:with] find_item selector jscript "pineappleVars.item.val('#{value}');" end |
#find_item(selector) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pineapple/utils/global_selector.rb', line 3 def find_item selector @script += <<SCRIPT pineappleVars.item = jQuery("##{selector}"); if(typeof pineappleVars.item.get(0) == "undefined"){ pineappleVars.item = jQuery("input[name='#{selector}']"); if(typeof pineappleVars.item.get(0) == "undefined"){ pineappleVars.item = jQuery(":contains('#{selector}')"); } if(typeof pineappleVars.item.get(0) == "undefined"){ pineappleVars.item = jQuery("#{selector}"); } } SCRIPT end |
#jscript(body) ⇒ Object
2 3 4 |
# File 'lib/pineapple/actions/script.rb', line 2 def jscript body @script += "#{body}\n" end |
#select(value, option) ⇒ Object
2 3 4 5 6 |
# File 'lib/pineapple/actions/select.rb', line 2 def select value, option selector = option[:from] find_item selector jscript "pineappleVars.item.val('#{value}');" end |
#uncheck(selector) ⇒ Object
2 3 4 5 |
# File 'lib/pineapple/actions/uncheck.rb', line 2 def uncheck selector find_item selector jscript "pineappleVars.item.attr('checked', false);" end |
#visit(url) ⇒ Object
2 3 4 |
# File 'lib/pineapple/actions/visit.rb', line 2 def visit url jscript "window.location.href = \"#{url}\";" end |