praline 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/praline.rb +23 -0
- metadata +2 -2
data/lib/praline.rb
CHANGED
@@ -21,41 +21,64 @@
|
|
21
21
|
|
22
22
|
require 'selenium-webdriver'
|
23
23
|
|
24
|
+
# @author Antoine d'Otreppe
|
24
25
|
module Praline
|
26
|
+
# Load the given URL in the browser
|
27
|
+
# @param [String] url the url to open
|
25
28
|
def open(url)
|
26
29
|
Praline::browser.get(url)
|
27
30
|
end
|
28
31
|
|
32
|
+
# Fill an input with the given text.
|
33
|
+
# Also works with <select> and checkbox elements
|
34
|
+
# @param [String] name the html name attribute of the target input
|
35
|
+
# @param [String] value the text to be put
|
29
36
|
def input(name, value)
|
30
37
|
Praline::browser.find_element(:name, name).send_keys(value)
|
31
38
|
end
|
32
39
|
|
40
|
+
# Get the current page title
|
41
|
+
# @return [String] the contents of the <title> tag of the current page
|
33
42
|
def title
|
34
43
|
Praline::browser.title
|
35
44
|
end
|
36
45
|
|
46
|
+
# Get the text of the <h1> of the current page.
|
47
|
+
# Will fail if there are several such tags
|
48
|
+
# @return [String] the text of the single <h1> tag of the current page
|
37
49
|
def h1
|
38
50
|
Praline::browser.find_element(:xpath, "//h1")
|
39
51
|
end
|
40
52
|
|
53
|
+
# Get the options' text from a specified select
|
54
|
+
# @param [String] select_name name of the select you want to poll
|
55
|
+
# @return [Array] array of the text values of the options in this select
|
41
56
|
def options(select_name)
|
42
57
|
select = Praline::browser.find_element(:name, select_name)
|
43
58
|
options = select.find_elements(:tag_name, 'option')
|
44
59
|
options.map {|option| option.text }
|
45
60
|
end
|
46
61
|
|
62
|
+
# Follow the specified link
|
63
|
+
# @param [String] link_text the text of the link to follow
|
47
64
|
def follow(link_text)
|
48
65
|
Praline::browser.find_element(:link, link_text).click
|
49
66
|
end
|
50
67
|
|
68
|
+
# Submit the specified form
|
69
|
+
# @param [String] form_name the html name of the form to submit
|
51
70
|
def submit(form_name)
|
52
71
|
Praline::browser.find_element(:name, form_name).submit
|
53
72
|
end
|
54
73
|
|
74
|
+
# Get the WebDriver itself, for in-depth manipulation
|
75
|
+
# @return [Selenium::WebDriver::Driver] the driver
|
55
76
|
def browser
|
56
77
|
Praline::browser
|
57
78
|
end
|
58
79
|
|
80
|
+
# Kill the browser.
|
81
|
+
# Call this when you are done with your script
|
59
82
|
def kill_browser
|
60
83
|
Praline::kill_browser
|
61
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: praline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: selenium-webdriver
|