honey-do 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/js/user-extensions.js +24 -8
- data/lib/honey_do.rb +2 -1
- data/test/file_upload_test.rb +8 -8
- data/test/select_list_test.rb +49 -7
- metadata +2 -2
data/Rakefile
CHANGED
data/js/user-extensions.js
CHANGED
@@ -18,23 +18,24 @@
|
|
18
18
|
Form_.PAIR_DELIMITER = ':::'
|
19
19
|
|
20
20
|
|
21
|
-
Form_.prototype.set_values = function(big_string, ok_if_not_found, select_as_text){
|
21
|
+
Form_.prototype.set_values = function(big_string, ok_if_not_found, select_as_text, select_exact_match){
|
22
22
|
var pairs = big_string.split(Form_.FIELD_DELIMITER), pair = [], error_values = '';
|
23
23
|
|
24
24
|
for(var i = 0; i < pairs.length; i++){
|
25
25
|
pair = pairs[i].split(Form_.PAIR_DELIMITER);
|
26
|
-
error_values += this.set_value(pair[0], pair[1], ok_if_not_found, select_as_text);
|
26
|
+
error_values += this.set_value(pair[0], pair[1], ok_if_not_found, select_as_text, select_exact_match);
|
27
27
|
}
|
28
28
|
return error_values;
|
29
29
|
}
|
30
30
|
|
31
|
-
Form_.prototype.set_value = function(name, value, ok_if_not_found, select_as_text){
|
31
|
+
Form_.prototype.set_value = function(name, value, ok_if_not_found, select_as_text, select_exact_match){
|
32
32
|
var error_text = '', e = null;
|
33
33
|
var selectable = /(select-one|select-multiple)/i;
|
34
34
|
var settable = /(text|textarea|password)/i;
|
35
35
|
var clickable = /(button|submit|reset|radio|image)/i;
|
36
36
|
Form_.SELECT_AS_TEXT = select_as_text;
|
37
|
-
|
37
|
+
Form_.SELECT_EXACT_MATCH = select_exact_match;
|
38
|
+
|
38
39
|
try {
|
39
40
|
// if you wanted to do something to explicitly wait for Ajax, you would do it here, before the element lookup
|
40
41
|
e = this.form.elements[name];
|
@@ -133,13 +134,18 @@
|
|
133
134
|
|
134
135
|
Form_.index_of_match = function(e, text_value) {
|
135
136
|
for ( var i = 0; i < e.options.length; i++) {
|
136
|
-
if (Form_.
|
137
|
-
|
137
|
+
if (Form_.SELECT_EXACT_MATCH) {
|
138
|
+
if (e.options[i].text == text_value) return i;
|
139
|
+
if (e.options[i].value == text_value) return i;
|
140
|
+
continue;
|
141
|
+
}
|
142
|
+
if (Form_.match_substring(e.options[i].text, text_value)) return i;
|
143
|
+
if (Form_.match_substring(e.options[i].value, text_value)) return i;
|
138
144
|
}
|
139
145
|
}
|
140
146
|
|
141
|
-
Form_.
|
142
|
-
return (within_string.search(new RegExp(
|
147
|
+
Form_.match_substring = function(within_string, sought_text_value) {
|
148
|
+
return (within_string.search(new RegExp(sought_text_value.custom_escape_special(),'i')) > -1);
|
143
149
|
}
|
144
150
|
|
145
151
|
Form_.prototype.droplist_size = function(element_name) {return Form_.index_of_last( this.form.elements[element_name] )}
|
@@ -278,6 +284,16 @@
|
|
278
284
|
if (e[i].type.toLowerCase() == 'checkbox') e[i].checked = true;
|
279
285
|
}
|
280
286
|
|
287
|
+
Form_.prototype.radio_button_names = function() {
|
288
|
+
var a = [];
|
289
|
+
var e = this.form.elements;
|
290
|
+
for(var i = 0;i < e.length; i++){
|
291
|
+
if (e[i].type.toLowerCase() == 'radio') a.push(e[i].name)
|
292
|
+
}
|
293
|
+
return a;
|
294
|
+
}
|
295
|
+
|
296
|
+
|
281
297
|
/* Table_ Class */
|
282
298
|
// Table_ class constructor: provides reference to aut document and a specified table
|
283
299
|
// table can be identified by name or index
|
data/lib/honey_do.rb
CHANGED
@@ -75,6 +75,7 @@ module HoneyDo
|
|
75
75
|
# <tt>:form_name_or_index</tt>:: Defaults to 0, because there is usually just one form per page. +String+ or +Integer+
|
76
76
|
# <tt>:ok_if_not_found</tt>:: +true+ to swallow the error, +nil+/+false+/+null+ if not present (the default). Useful for testing multiple versions of your app when names have changed, or widgets have been added or removed.
|
77
77
|
# <tt>:select_as_text</tt>:: +true+ to force droplist values to be treated as text, even if they are digits +nil+/+false+/+null+ if not present (the default). Useful when the visible option text is a number (e.g., "day of month" lists). Without it, the input is taken to an index.
|
78
|
+
# <tt>:select_exact_match</tt>:: +true+ to match entire droplist value (+text+ or +value+ attribute), overriding default substring match.
|
78
79
|
# <tt>:one_field_at_a_time</tt>:: +true+ to use mulitple-call mode. Makes Ruby loop on the list, instead JavaScript, forcing a separate <tt>get_eval</tt> call for each item. Effectively slows it down as a means of handling _Ajax_ refreshes in _Firefox_.
|
79
80
|
# <tt>:retry_max</tt>:: 0 or 1 to *_not_* retry at all. Anything > 2 (the default, which means 1 try and 1 retry) is probably useless, but I don't know your app. +Integer+
|
80
81
|
# <tt>:retry_interval</tt>:: To change the default wait time (0.75 seconds) between retries. +Float+
|
@@ -89,7 +90,7 @@ module HoneyDo
|
|
89
90
|
retry_interval = processing_params[:retry_interval] ? processing_params[:retry_interval] : 0.75
|
90
91
|
|
91
92
|
js_open = "dom=new Form_( this, '#{which_form}' )."
|
92
|
-
js_close = ", '#{processing_params[:ok_if_not_found]}', '#{processing_params[:select_as_text]}' )"
|
93
|
+
js_close = ", '#{processing_params[:ok_if_not_found]}', '#{processing_params[:select_as_text]}', '#{processing_params[:select_exact_match]}' )"
|
93
94
|
errors = ""
|
94
95
|
|
95
96
|
# when input is a single symbol or int
|
data/test/file_upload_test.rb
CHANGED
@@ -2,14 +2,14 @@ require 'test_master'
|
|
2
2
|
|
3
3
|
class TestFileUpload < Test::Unit::TestCase
|
4
4
|
|
5
|
-
#
|
6
|
-
def test_file_upload_by_selenium_not_permitted_by_firefox
|
7
|
-
return if ie?
|
8
|
-
navigate
|
9
|
-
assert_raise(SeleniumCommandError) do
|
10
|
-
browser.type("dom=document.everything.file", "foo.txt")
|
11
|
-
end
|
12
|
-
end
|
5
|
+
# # this error no longer occurs as of Selenium 1.01b1, ff 2.0.0.20
|
6
|
+
# def test_file_upload_by_selenium_not_permitted_by_firefox
|
7
|
+
# return if ie?
|
8
|
+
# navigate
|
9
|
+
# assert_raise(SeleniumCommandError) do
|
10
|
+
# browser.type("dom=document.everything.file", "foo.txt")
|
11
|
+
# end
|
12
|
+
# end
|
13
13
|
|
14
14
|
def test_file_upload_not_implemented
|
15
15
|
navigate
|
data/test/select_list_test.rb
CHANGED
@@ -30,18 +30,18 @@ class TestSelectFeatures < Test::Unit::TestCase
|
|
30
30
|
assert_equal(option_text_property, browser.get_form_values[:color], "case insensitive")
|
31
31
|
end
|
32
32
|
|
33
|
-
#
|
33
|
+
# *, ? and + are just text (not wildcards)
|
34
34
|
def test_select_from_droplist_by_substring_match_on_visible_text
|
35
35
|
default_selection = browser.get_form_values[:color]
|
36
36
|
|
37
|
-
test_intent = "substring
|
37
|
+
test_intent = "substring match"
|
38
38
|
browser.set_form_values(:color => "ligh")
|
39
39
|
assert_equal("Light Grey", browser.get_form_values[:color], test_intent)
|
40
40
|
|
41
|
-
|
41
|
+
assert_nothing_raised(RuntimeError, test_intent) do
|
42
42
|
reset_then_set_without_retry(:color => "ight Grey")
|
43
43
|
end
|
44
|
-
assert_equal(
|
44
|
+
assert_equal("Light Grey", browser.get_form_values[:color], test_intent)
|
45
45
|
|
46
46
|
test_intent = "substring: no wildcards"
|
47
47
|
assert_raise(RuntimeError, test_intent) do
|
@@ -56,14 +56,14 @@ class TestSelectFeatures < Test::Unit::TestCase
|
|
56
56
|
option_value_property = "flat eggshell white"
|
57
57
|
option_text_property = "Off White"
|
58
58
|
|
59
|
-
test_intent = "substring
|
59
|
+
test_intent = "substring match"
|
60
60
|
browser.set_form_values(:color => "Flat Egg")
|
61
61
|
assert_equal(option_text_property, browser.get_form_values[:color], test_intent)
|
62
62
|
|
63
|
-
|
63
|
+
assert_nothing_raised(RuntimeError, test_intent) do
|
64
64
|
reset_then_set_without_retry(:color => "hell white")
|
65
65
|
end
|
66
|
-
assert_equal(
|
66
|
+
assert_equal(option_text_property, browser.get_form_values[:color], test_intent)
|
67
67
|
|
68
68
|
test_intent = "substring: no wildcards"
|
69
69
|
assert_raise(RuntimeError, test_intent) do
|
@@ -86,6 +86,48 @@ class TestSelectFeatures < Test::Unit::TestCase
|
|
86
86
|
assert_equal(default_selection, browser.get_form_values[:color], test_intent)
|
87
87
|
end
|
88
88
|
|
89
|
+
def test_select_from_droplist_by_exact_match
|
90
|
+
browser.set_form_values({:color => "Light Grey"}, {:select_exact_match => true})
|
91
|
+
assert_equal("Light Grey", browser.get_form_values[:color], "selection of complete string in exact match mode" )
|
92
|
+
|
93
|
+
browser.set_form_values(:resetButton)
|
94
|
+
|
95
|
+
browser.set_form_values({:color => "light grey"}, {:select_exact_match => true})
|
96
|
+
assert_equal("Light Grey", browser.get_form_values[:color], "selection of complete string in exact match mode, using value property" )
|
97
|
+
|
98
|
+
assert_raise(RuntimeError, "substring in exact match mode fails") do
|
99
|
+
browser.set_form_values({:color => "Light"}, {:select_exact_match => true})
|
100
|
+
end
|
101
|
+
|
102
|
+
assert_raise(RuntimeError, "substring in exact match mode fails") do
|
103
|
+
browser.set_form_values({:color => "t Grey"}, {:select_exact_match => true})
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_raise(RuntimeError, "substring of value property in exact match mode fails") do
|
107
|
+
browser.set_form_values({:color => "re"}, {:select_exact_match => true})
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_select_from_multi_select_by_exact_match
|
113
|
+
full_string = "Annoying my friends"
|
114
|
+
browser.set_form_values({:hobbies => full_string}, {:select_exact_match => true})
|
115
|
+
assert_equal(full_string, browser.get_form_values[:hobbies], "selection of complete string in exact match mode" )
|
116
|
+
|
117
|
+
browser.set_form_values(:resetButton)
|
118
|
+
|
119
|
+
browser.set_form_values({:hobbies => "annoying"}, {:select_exact_match => true})
|
120
|
+
assert_equal(full_string, browser.get_form_values[:hobbies], "selection of complete string in exact match mode, using value property" )
|
121
|
+
|
122
|
+
assert_raise(RuntimeError, "substring in exact match mode fails") do
|
123
|
+
browser.set_form_values({:hobbies => "Annoying"}, {:select_exact_match => true})
|
124
|
+
end
|
125
|
+
|
126
|
+
assert_raise(RuntimeError, "substring in exact match mode fails") do
|
127
|
+
browser.set_form_values({:hobbies => "my friends"}, {:select_exact_match => true})
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
89
131
|
def test_select_from_multi_select_by_index
|
90
132
|
assert_nil(browser.get_form_values[:hobbies], "this multi-select has no default")
|
91
133
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: honey-do
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Camper
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-02-10 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|