Module: Girbot::WatirShortcuts
- Included in:
- Step
- Defined in:
- lib/girbot/watir_shortcuts.rb
Instance Method Summary collapse
- #append_to_textfield(text, query) ⇒ Object
- #browser ⇒ Object
-
#click(type, query) ⇒ Object
Examples:.
- #close ⇒ Object
- #exec_js(js) ⇒ Object
-
#fire_event(type, query, event = :click) ⇒ Object
Examples:.
- #goto(url) ⇒ Object
- #maximize ⇒ Object
- #select_value(value, query) ⇒ Object
- #text_in_textfield(text, query) ⇒ Object
Instance Method Details
#append_to_textfield(text, query) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/girbot/watir_shortcuts.rb', line 23 def append_to_textfield text, query input = browser.text_field(query) text.chars.each do |c| input.append(c) end end |
#browser ⇒ Object
3 4 5 |
# File 'lib/girbot/watir_shortcuts.rb', line 3 def browser @browser_holder.browser end |
#click(type, query) ⇒ Object
Examples:
click(:button, id: 'my-id')
click(:button, type: 'submit')
43 44 45 |
# File 'lib/girbot/watir_shortcuts.rb', line 43 def click(type, query) browser.send(type, query).click end |
#close ⇒ Object
56 57 58 |
# File 'lib/girbot/watir_shortcuts.rb', line 56 def close browser.close end |
#exec_js(js) ⇒ Object
30 31 32 |
# File 'lib/girbot/watir_shortcuts.rb', line 30 def exec_js js browser.execute_script(js) end |
#fire_event(type, query, event = :click) ⇒ Object
Examples:
fire_event(:checkbox, id: 'my-id')
fire_event(:checkbox, class: 'my-class', :click)
52 53 54 |
# File 'lib/girbot/watir_shortcuts.rb', line 52 def fire_event(type, query, event = :click) browser.send(type, query).fire_event event end |
#goto(url) ⇒ Object
15 16 17 |
# File 'lib/girbot/watir_shortcuts.rb', line 15 def goto url browser.goto url end |
#maximize ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/girbot/watir_shortcuts.rb', line 7 def maximize browser.driver.manage.window.maximize rescue Selenium::WebDriver::Error::UnknownError => e puts 'Could not maximize. Moving on.' puts e puts e.backtrace end |
#select_value(value, query) ⇒ Object
34 35 36 |
# File 'lib/girbot/watir_shortcuts.rb', line 34 def select_value(value, query) browser.select_list(query).select_value(value) end |
#text_in_textfield(text, query) ⇒ Object
19 20 21 |
# File 'lib/girbot/watir_shortcuts.rb', line 19 def text_in_textfield text, query browser.text_field(query).set text end |