module Girbot::WatirShortcuts
Public Instance Methods
append_to_textfield(text, query)
click to toggle source
# 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()
click to toggle source
# File lib/girbot/watir_shortcuts.rb, line 3 def browser @browser_holder.browser end
click(type, query)
click to toggle source
Examples:
click(:button, id: 'my-id') click(:button, type: 'submit')
# File lib/girbot/watir_shortcuts.rb, line 43 def click(type, query) browser.send(type, query).click end
close()
click to toggle source
# File lib/girbot/watir_shortcuts.rb, line 66 def close browser.close end
exec_js(js)
click to toggle source
# File lib/girbot/watir_shortcuts.rb, line 30 def exec_js js browser.execute_script(js) end
fire_event(type, query, event = :click)
click to toggle source
Examples:
fire_event(:checkbox, id: 'my-id') fire_event(:checkbox, class: 'my-class', :click)
# 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)
click to toggle source
# File lib/girbot/watir_shortcuts.rb, line 15 def goto url browser.goto url end
maximize()
click to toggle source
# 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
screenshot(label, preview = false)
click to toggle source
# File lib/girbot/watir_shortcuts.rb, line 56 def screenshot(label, preview = false) timestamp = Time.now.strftime("%F %T") result = browser.screenshot.save "screenshots/#{label}-#{timestamp}.png" if preview pid = spawn("xdg-open #{result.path}") Process.detach(pid) end result end
select_value(value, query)
click to toggle source
# File lib/girbot/watir_shortcuts.rb, line 34 def select_value(value, query) browser.select_list(query).select(value) end
text_in_textfield(text, query)
click to toggle source
# File lib/girbot/watir_shortcuts.rb, line 19 def text_in_textfield text, query browser.text_field(query).set text end