lapis_lazuli 0.9.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lapis_lazuli.gemspec +12 -0
- data/lib/lapis_lazuli.rb +1 -1
- data/lib/lapis_lazuli/api.rb +1 -1
- data/lib/lapis_lazuli/argparse.rb +1 -1
- data/lib/lapis_lazuli/browser.rb +1 -1
- data/lib/lapis_lazuli/browser/error.rb +1 -1
- data/lib/lapis_lazuli/browser/find.rb +1 -1
- data/lib/lapis_lazuli/browser/interaction.rb +1 -1
- data/lib/lapis_lazuli/browser/remote.rb +1 -1
- data/lib/lapis_lazuli/browser/screenshots.rb +1 -1
- data/lib/lapis_lazuli/browser/wait.rb +23 -12
- data/lib/lapis_lazuli/cli.rb +1 -1
- data/lib/lapis_lazuli/cucumber.rb +1 -1
- data/lib/lapis_lazuli/generators/cucumber.rb +1 -1
- data/lib/lapis_lazuli/generators/cucumber/template/Gemfile +3 -7
- data/lib/lapis_lazuli/generators/cucumber/template/README.md +3 -1
- data/lib/lapis_lazuli/generators/cucumber/template/config/config.yml +32 -2
- data/lib/lapis_lazuli/generators/cucumber/template/config/cucumber.yml +0 -9
- data/lib/lapis_lazuli/generators/cucumber/template/features/account.feature +26 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/example.feature +23 -10
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/interaction_steps.rb +135 -7
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/precondition_steps.rb +52 -3
- data/lib/lapis_lazuli/generators/cucumber/template/features/step_definitions/validation_steps.rb +44 -0
- data/lib/lapis_lazuli/generators/cucumber/template/features/support/env.rb +29 -1
- data/lib/lapis_lazuli/generators/cucumber/template/features/support/functions.rb +68 -0
- data/lib/lapis_lazuli/generic/xpath.rb +1 -1
- data/lib/lapis_lazuli/options.rb +1 -1
- data/lib/lapis_lazuli/placeholders.rb +1 -1
- data/lib/lapis_lazuli/proxy.rb +1 -1
- data/lib/lapis_lazuli/runtime.rb +1 -1
- data/lib/lapis_lazuli/scenario.rb +1 -1
- data/lib/lapis_lazuli/storage.rb +1 -1
- data/lib/lapis_lazuli/version.rb +2 -2
- data/lib/lapis_lazuli/versions.rb +1 -1
- data/lib/lapis_lazuli/world/annotate.rb +1 -1
- data/lib/lapis_lazuli/world/api.rb +1 -1
- data/lib/lapis_lazuli/world/browser.rb +1 -1
- data/lib/lapis_lazuli/world/config.rb +1 -1
- data/lib/lapis_lazuli/world/error.rb +1 -1
- data/lib/lapis_lazuli/world/hooks.rb +1 -1
- data/lib/lapis_lazuli/world/logging.rb +1 -1
- data/lib/lapis_lazuli/world/proxy.rb +1 -1
- data/lib/lapis_lazuli/world/variable.rb +1 -1
- data/test/Gemfile +10 -33
- data/test/features/step_definitions/interaction_steps.rb +25 -3
- data/test/features/step_definitions/validation_steps.rb +265 -230
- data/test/features/timing.feature +40 -4
- data/test/server/www/timing.html +15 -0
- metadata +90 -4
@@ -11,7 +11,7 @@ Given(/^I navigate to the (.*) test page$/) do |page|
|
|
11
11
|
config = "server.url"
|
12
12
|
if has_env?(config)
|
13
13
|
url = env(config)
|
14
|
-
browser.goto "#{url}#{page.downcase.gsub(" ","_")}.html"
|
14
|
+
browser.goto "#{url}#{page.downcase.gsub(" ", "_")}.html"
|
15
15
|
else
|
16
16
|
error(:env => config)
|
17
17
|
end
|
@@ -19,10 +19,10 @@ end
|
|
19
19
|
|
20
20
|
Given(/I click (the|a) (first|last|random|[0-9]+[a-z]+) (.*)$/) do |arg1, index, type|
|
21
21
|
# Convert the type text to a symbol
|
22
|
-
type = type.downcase.gsub(" ","_")
|
22
|
+
type = type.downcase.gsub(" ", "_")
|
23
23
|
|
24
24
|
pick = 0
|
25
|
-
if ["first","last","random"].include?(index)
|
25
|
+
if ["first", "last", "random"].include?(index)
|
26
26
|
pick = index.to_sym
|
27
27
|
else
|
28
28
|
pick = index.to_i - 1
|
@@ -66,6 +66,28 @@ When(/^I find "(.*?)" and name it "(.*?)"$/) do |id, name|
|
|
66
66
|
scenario.storage.set(name, element)
|
67
67
|
end
|
68
68
|
|
69
|
+
When(/^I wait for (class )?"(.*?)" and name it "(.*?)"$/) do |type, id, name|
|
70
|
+
type = 'id' if type.nil? || type.empty?
|
71
|
+
type.strip!
|
72
|
+
element = browser.wait(:element => {type.to_sym => id})
|
73
|
+
scenario.storage.set(name, element)
|
74
|
+
end
|
75
|
+
|
76
|
+
When(/^no error should be thrown when waiting for "(.*?)"$/) do |id|
|
77
|
+
begin
|
78
|
+
elm = browser.wait(
|
79
|
+
:element => {:id => id},
|
80
|
+
:timeout => 3,
|
81
|
+
:throw => false
|
82
|
+
)
|
83
|
+
rescue
|
84
|
+
raise 'An error was thrown using a wait funtion with :throw => false'
|
85
|
+
end
|
86
|
+
if not elm.nil?
|
87
|
+
raise 'No element was suppose to be found, but it did have a value after the wait action.'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
69
91
|
xpath_fragment = nil
|
70
92
|
Given(/^I specify a needle "(.+?)" and a node "(.+?)" (and an empty separator )?to xp_contains$/) do |needle, node, empty_sep|
|
71
93
|
if empty_sep.nil?
|
@@ -8,163 +8,168 @@ require 'test/unit/assertions'
|
|
8
8
|
include Test::Unit::Assertions
|
9
9
|
|
10
10
|
Then(/(first|last|random|[0-9]+[a-z]+) (.*) should (not )?be the (first|last|[0-9]+[a-z]+) element on the page$/) do |index, type, differ, location_on_page|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
11
|
+
# Convert the type text to a symbol
|
12
|
+
type = type.downcase.gsub(" ", "_")
|
13
|
+
|
14
|
+
pick = 0
|
15
|
+
if ["first", "last", "random"].include?(index)
|
16
|
+
pick = index.to_sym
|
17
|
+
else
|
18
|
+
pick = index.to_i - 1
|
19
|
+
end
|
20
|
+
# Options for find
|
21
|
+
options = {}
|
22
|
+
# Select the correct element
|
23
|
+
options[type.to_sym] = {}
|
24
|
+
# Pick the correct one
|
25
|
+
options[:pick] = pick
|
26
|
+
# Execute the find
|
27
|
+
type_element = browser.find(options)
|
28
|
+
|
29
|
+
# All elements on the page
|
30
|
+
body_elements = browser.body.elements
|
31
|
+
# Find the element we need
|
32
|
+
page_element = nil
|
33
|
+
if location_on_page == "first"
|
34
|
+
page_element = body_elements.first
|
35
|
+
elsif location_on_page == "last"
|
36
|
+
page_element = body_elements.last
|
37
|
+
else
|
38
|
+
page_element = body_elements[location_on_page.to_i - 1]
|
39
|
+
end
|
40
|
+
|
41
|
+
# No page element
|
42
|
+
if not page_element
|
43
|
+
error("Could not find an element on the page")
|
44
|
+
# Elements are the same but it should not be
|
45
|
+
elsif page_element == type_element and differ
|
46
|
+
error("Elements on the page are the same")
|
47
|
+
# Elements are different but should be the same
|
48
|
+
elsif page_element != type_element and not differ
|
49
|
+
error("Elements should be the same")
|
50
|
+
end
|
51
51
|
end
|
52
52
|
|
53
53
|
Then(/(first|last|random|[0-9]+[a-z]+) (.*) should (not )?be present$/) do |index, type, hidden|
|
54
54
|
# Convert the type text to a symbol
|
55
|
-
|
55
|
+
type = type.downcase.gsub(" ", "_")
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
pick = 0
|
58
|
+
if ["first", "last", "random"].include?(index)
|
59
|
+
pick = index.to_sym
|
60
|
+
else
|
61
|
+
pick = index.to_i - 1
|
62
|
+
end
|
63
63
|
|
64
|
-
|
64
|
+
# Options for find_all
|
65
65
|
options = {}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
66
|
+
# Select the correct element
|
67
|
+
options[type.to_sym] = {}
|
68
|
+
# Pick the correct one
|
69
|
+
options[:pick] = pick
|
70
|
+
# Execute the find
|
71
|
+
type_element = browser.find(options)
|
72
|
+
# Find all
|
73
|
+
all_elements = browser.find_all(options)
|
74
74
|
|
75
75
|
options[:filter_by] = :present?
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
76
|
+
all_present = browser.find_all(options)
|
77
|
+
|
78
|
+
if hidden and type_element.present?
|
79
|
+
error("Hidden element is visible")
|
80
|
+
elsif not hidden and not type_element.present?
|
81
|
+
error("Element is hidden")
|
82
|
+
elsif hidden and not type_element.present? and
|
83
|
+
(not all_elements.include?(type_element) or all_present.include?(type_element))
|
84
|
+
error("Hidden element (not) found via find_all(:filter_by => :present?)")
|
85
|
+
elsif not hidden and type_element.present? and
|
86
|
+
(not all_elements.include?(type_element) or not all_present.include?(type_element))
|
87
|
+
error("Visible element (not) found via find_all(:filter_by => :present?)")
|
88
|
+
end
|
89
89
|
end
|
90
90
|
|
91
91
|
Then(/^within (\d+) seconds I should see "([^"]+?)"( disappear)?$/) do |timeout, text, condition|
|
92
92
|
if condition
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
93
|
+
condition = :while
|
94
|
+
else
|
95
|
+
condition = :until
|
96
|
+
end
|
97
|
+
|
98
|
+
browser.wait(
|
99
|
+
:timeout => timeout,
|
100
|
+
:text => text,
|
101
|
+
:condition => condition,
|
102
|
+
:groups => ["wait"]
|
103
|
+
)
|
104
104
|
end
|
105
105
|
|
106
106
|
Then(/^within (\d+) seconds I should see "([^"]+?)" and "([^"]+?)"( disappear)?$/) do |timeout, first, second, condition|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
107
|
+
if condition
|
108
|
+
condition = :while
|
109
|
+
else
|
110
|
+
condition = :until
|
111
|
+
end
|
112
|
+
|
113
|
+
browser.multi_wait_all(
|
114
|
+
:timeout => timeout,
|
115
|
+
:condition => condition,
|
116
|
+
:mode => :match_all,
|
117
|
+
:groups => ["wait"],
|
118
|
+
:selectors => [
|
119
|
+
{:tag_name => 'span', :class => /foo/},
|
120
|
+
{:tag_name => 'div', :id => 'bar'}
|
121
|
+
]
|
122
|
+
)
|
123
123
|
end
|
124
124
|
|
125
125
|
Then(/^within (\d+) seconds I should see added elements with matching$/) do |timeout|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
126
|
+
elems = browser.multi_wait_all(
|
127
|
+
:timeout => timeout,
|
128
|
+
:condition => :until,
|
129
|
+
:mode => :match_all,
|
130
|
+
:groups => ["wait"],
|
131
|
+
:selectors => [
|
132
|
+
{:tag_name => 'span', :class => /foo/, :text => /foo/},
|
133
|
+
{:tag_name => 'div', :id => 'bar', :html => "bar"}
|
134
|
+
]
|
135
|
+
)
|
136
|
+
assert (2 == elems.length), "Expected two elements, found #{elems.length}"
|
137
137
|
end
|
138
138
|
|
139
139
|
Then(/^within 10 seconds I should see either added element/) do
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
browser.multi_wait_all(
|
141
|
+
{:tag_name => 'a', :class => /foo/},
|
142
|
+
{:tag_name => 'div', :id => 'bar'}
|
143
|
+
)
|
144
144
|
end
|
145
145
|
|
146
146
|
Then(/^within (\d+) seconds I get an error waiting for "(.*?)"( to disappear)?$/) do |timeout, text, condition|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
147
|
+
if condition
|
148
|
+
condition = :while
|
149
|
+
else
|
150
|
+
condition = :until
|
151
|
+
end
|
152
|
+
|
153
|
+
error_thrown = false
|
154
|
+
begin
|
155
|
+
browser.wait(
|
156
|
+
:timeout => timeout,
|
157
|
+
:text => text,
|
158
|
+
:condition => condition,
|
159
|
+
:screenshot => true,
|
160
|
+
:groups => ["wait"]
|
161
|
+
)
|
162
|
+
rescue RuntimeError => err
|
163
|
+
error_thrown = true
|
164
|
+
end
|
165
|
+
unless error_thrown
|
166
|
+
# Only show an error if there was no error thrown before.
|
167
|
+
error(
|
168
|
+
:message => "Didn't receive an error with this timeout",
|
169
|
+
:screenshot => true,
|
170
|
+
:groups => ["wait"]
|
171
|
+
)
|
172
|
+
end
|
168
173
|
end
|
169
174
|
|
170
175
|
|
@@ -182,118 +187,141 @@ end
|
|
182
187
|
|
183
188
|
|
184
189
|
Then(/^a screenshot should have been created$/) do
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
190
|
+
# Check if there is a screenshot with the correct name
|
191
|
+
name = browser.screenshot_name
|
192
|
+
if Dir[name].empty?
|
193
|
+
error(
|
194
|
+
:message => "Didn't find a screenshot for this scenario: #{name}",
|
195
|
+
:groups => ["screenshot"]
|
196
|
+
)
|
197
|
+
end
|
193
198
|
end
|
194
199
|
|
195
200
|
Then(/^I expect javascript errors$/) do
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
201
|
+
errors = browser.get_js_errors
|
202
|
+
if !errors.nil? and errors.length > 0
|
203
|
+
scenario.check_browser_errors = false
|
204
|
+
else
|
205
|
+
error(
|
206
|
+
:message => "No Javascript errors detected",
|
207
|
+
:groups => ["error"]
|
208
|
+
)
|
209
|
+
end
|
205
210
|
end
|
206
211
|
|
207
212
|
Then(/^I expect a (\d+) status code$/) do |expected|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
213
|
+
expected = expected.to_i
|
214
|
+
if browser.get_http_status == expected && expected > 299
|
215
|
+
scenario.check_browser_errors = false
|
216
|
+
elsif browser.get_http_status != expected
|
217
|
+
error(
|
218
|
+
:message => "Incorrect status code: #{browser.get_http_status}",
|
219
|
+
:groups => ["error"]
|
220
|
+
)
|
221
|
+
end
|
217
222
|
end
|
218
223
|
|
219
224
|
Then(/^I expect (no|\d+) HTML errors?$/) do |expected|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
225
|
+
expected = expected.to_i
|
226
|
+
scenario.check_browser_errors = false
|
227
|
+
if browser.get_html_errors.length != expected
|
228
|
+
error(
|
229
|
+
:message => "Expected #{expected} errors: #{browser.get_html_errors}",
|
230
|
+
:groups => ["error"]
|
231
|
+
)
|
232
|
+
end
|
228
233
|
end
|
229
234
|
|
230
235
|
Then(/^the firefox browser named "(.*?)" has a profile$/) do |name|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
236
|
+
if scenario.storage.has? name
|
237
|
+
browser = scenario.storage.get name
|
238
|
+
if browser.browser_name == "remote"
|
239
|
+
if browser.driver.capabilities.firefox_profile.nil?
|
240
|
+
raise "Remote Firefox Profile is not set"
|
241
|
+
end
|
242
|
+
else
|
243
|
+
if browser.optional_data.has_key? "profile" or browser.optional_data.has_key? :profile
|
244
|
+
raise "No profile found in the optional data"
|
245
|
+
end
|
246
|
+
end
|
247
|
+
else
|
248
|
+
error("No item in the storage named #{name}")
|
249
|
+
end
|
245
250
|
end
|
246
251
|
|
247
252
|
Then(/^I expect the "(.*?)" to exist$/) do |name|
|
248
|
-
|
253
|
+
browser.find(name)
|
249
254
|
end
|
250
255
|
|
251
256
|
Then(/^I expect an? (.*?) element to exist$/) do |element|
|
252
|
-
|
257
|
+
browser.find(element.to_sym)
|
253
258
|
end
|
254
259
|
|
255
260
|
Then(/^I expect to find an? (.*?) element with (.*?) "(.*?)" using (.*?) settings$/) do |element, attribute, text, setting_choice|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
261
|
+
settings = {
|
262
|
+
"method" => {element.downcase => {attribute.to_sym => /#{text}/}},
|
263
|
+
"like with hash" => {:like => {
|
264
|
+
:element => element.downcase,
|
265
|
+
:attribute => attribute,
|
266
|
+
:include => text
|
267
|
+
}},
|
268
|
+
"like with array" => {:like => [element.downcase, attribute, text]},
|
269
|
+
"tag name" => {:tag_name => element.downcase, attribute.to_sym => /#{text}/}
|
270
|
+
}
|
271
|
+
setting = settings[setting_choice]
|
272
|
+
# Find always throws an error if not found
|
273
|
+
elem_find = browser.find(setting)
|
274
|
+
elem_findall = browser.find_all(setting).first
|
275
|
+
if elem_find != elem_findall
|
276
|
+
error "Incorrect results"
|
277
|
+
end
|
273
278
|
end
|
274
279
|
|
275
280
|
Then(/^I expect to find an? (.*?) element or an? (.*?) element$/) do |element1, element2|
|
276
|
-
|
281
|
+
element = browser.multi_find(element1.to_sym, element2.to_sym)
|
277
282
|
end
|
278
283
|
|
279
284
|
Then(/^I should (not )?find "(.*?)" ([0-9]+ times )?using "(.*?)" as context$/) do |result, id, number, name|
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
285
|
+
context = scenario.storage.get name
|
286
|
+
if context.nil?
|
287
|
+
error(:not_found => "Find context in storage")
|
288
|
+
end
|
289
|
+
begin
|
290
|
+
settings = {:element => id, :context => context}
|
291
|
+
settings[:filter_by] = :present?
|
292
|
+
settings[:throw] = false
|
293
|
+
elements = browser.find_all(settings)
|
294
|
+
if not number.nil? and elements.length != number.to_i
|
295
|
+
error("Incorrect number of elements: #{elements.length}")
|
296
|
+
end
|
297
|
+
rescue
|
298
|
+
if result.nil?
|
299
|
+
raise $!
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
Then(/^I should (not )?wait for "(.*?)" ([0-9]+ times )?using "(.*?)" as context$/) do |result, id, number, name|
|
305
|
+
context = scenario.storage.get name
|
306
|
+
if context.nil?
|
307
|
+
error(:not_found => "Find context in storage")
|
308
|
+
end
|
309
|
+
begin
|
310
|
+
settings = {:element => id, :context => context}
|
311
|
+
settings[:filter_by] = :present?
|
312
|
+
settings[:throw] = false
|
313
|
+
settings[:timeout] = 10
|
314
|
+
elements = browser.wait_all(settings)
|
315
|
+
if not number.nil? and elements.length != number.to_i
|
316
|
+
error("Incorrect number of elements: #{elements.length}")
|
317
|
+
elsif elements.length > 0
|
318
|
+
scenario.storage.set('last_element', elements[0])
|
319
|
+
end
|
320
|
+
rescue
|
321
|
+
if result.nil?
|
322
|
+
raise $!
|
323
|
+
end
|
324
|
+
end
|
297
325
|
end
|
298
326
|
|
299
327
|
Given(/^I generate and store an email$/) do
|
@@ -321,12 +349,12 @@ end
|
|
321
349
|
Then(/^I expect the (world|browser) module's functions to be available$/) do |type|
|
322
350
|
# We're essentially testing that NoMethodError is not being raised here.
|
323
351
|
case type
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
352
|
+
when "browser"
|
353
|
+
browser.test_func
|
354
|
+
when "world"
|
355
|
+
test_func
|
356
|
+
else
|
357
|
+
raise "No such module type: #{type}"
|
330
358
|
end
|
331
359
|
end
|
332
360
|
|
@@ -354,14 +382,21 @@ Then(/^I expect to use tagname to hash options to (.*?) find element (.*?)$/) do
|
|
354
382
|
end
|
355
383
|
end
|
356
384
|
|
357
|
-
Then(/^the environment variable "(.*?)" is set to "(.*?)"$/) do |var,val|
|
358
|
-
|
359
|
-
|
385
|
+
Then(/^the environment variable "(.*?)" is set to "(.*?)"$/) do |var, val|
|
386
|
+
value = env(var)
|
387
|
+
assert_equal val, value, "Incorrect value"
|
360
388
|
end
|
361
389
|
|
362
390
|
Then(/^the environment variable "(.*?)" has "(.*?)" set to "(.*?)"$/) do |var, key, val|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
391
|
+
hash = env(var, {})
|
392
|
+
assert hash.is_a?(Hash), "Config element is not a Hash: #{hash}"
|
393
|
+
assert hash.has_key?(key), "Config is missing #{key}"
|
394
|
+
assert_equal hash[key], val, "Config has incorrect value"
|
367
395
|
end
|
396
|
+
|
397
|
+
Then(/^that element should not container text "(.*?)"$/) do |text|
|
398
|
+
element = scenario.storage.get 'last_element'
|
399
|
+
if element.text.include? text
|
400
|
+
raise 'Element did contain the text it should not contain.'
|
401
|
+
end
|
402
|
+
end
|