Module: Praline
- Defined in:
- lib/praline.rb
Overview
Instance Method Summary collapse
-
#browser ⇒ Selenium::WebDriver::Driver
Get the WebDriver itself, for in-depth manipulation.
-
#follow(link_text) ⇒ Object
Follow the specified link.
-
#h1 ⇒ String
Get the text of the <h1> of the current page.
-
#input(name, value) ⇒ Object
Fill an input with the given text.
-
#kill_browser ⇒ Object
Kill the browser.
-
#open(url) ⇒ Object
Load the given URL in the browser.
-
#options(select_name) ⇒ Array
Get the options’ text from a specified select.
-
#submit(form_name) ⇒ Object
Submit the specified form.
-
#title ⇒ String
Get the current page title.
Instance Method Details
#browser ⇒ Selenium::WebDriver::Driver
Get the WebDriver itself, for in-depth manipulation
76 77 78 |
# File 'lib/praline.rb', line 76 def browser Praline::browser end |
#follow(link_text) ⇒ Object
Follow the specified link
64 65 66 |
# File 'lib/praline.rb', line 64 def follow(link_text) Praline::browser.find_element(:link, link_text).click end |
#h1 ⇒ String
Get the text of the <h1> of the current page. Will fail if there are several such tags
49 50 51 |
# File 'lib/praline.rb', line 49 def h1 Praline::browser.find_element(:xpath, "//h1") end |
#input(name, value) ⇒ Object
Fill an input with the given text. Also works with <select> and checkbox elements
36 37 38 |
# File 'lib/praline.rb', line 36 def input(name, value) Praline::browser.find_element(:name, name).send_keys(value) end |
#kill_browser ⇒ Object
Kill the browser. Call this when you are done with your script
82 83 84 |
# File 'lib/praline.rb', line 82 def kill_browser Praline::kill_browser end |
#open(url) ⇒ Object
Load the given URL in the browser
28 29 30 |
# File 'lib/praline.rb', line 28 def open(url) Praline::browser.get(url) end |
#options(select_name) ⇒ Array
Get the options’ text from a specified select
56 57 58 59 60 |
# File 'lib/praline.rb', line 56 def (select_name) select = Praline::browser.find_element(:name, select_name) = select.find_elements(:tag_name, 'option') .map {|option| option.text } end |
#submit(form_name) ⇒ Object
Submit the specified form
70 71 72 |
# File 'lib/praline.rb', line 70 def submit(form_name) Praline::browser.find_element(:name, form_name).submit end |
#title ⇒ String
Get the current page title
42 43 44 |
# File 'lib/praline.rb', line 42 def title Praline::browser.title end |