cuke_master 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cuke_master/steps.rb +40 -15
- data/lib/cuke_master/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb2250806db91cdb21f214bd0cb36c59893337a9
|
4
|
+
data.tar.gz: 30b89b34c02f1657e3fd594efe5e7efb82bd49da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec4276d601dcb77e8d88a118f5cbce34a02c20334ec37cb93b45e9ad9332cbdd259470856627993aeb6603794f8e530578e1f155d7413021cecb5aa93840418
|
7
|
+
data.tar.gz: 56ce9324c4a24dadb65c02f652f7eed06b1a18872ae6f56224be6771a1454912eb656b2479105079a01bb02c069d5918535fe4bf342f5728b3f547daf3298225
|
data/lib/cuke_master/steps.rb
CHANGED
@@ -5,6 +5,11 @@
|
|
5
5
|
When(/^I visit the url "([^"]*)"$/) do |url|
|
6
6
|
visit url
|
7
7
|
@pos_number = {
|
8
|
+
fifth_last: -4,
|
9
|
+
fourthlast: -3,
|
10
|
+
third_last: -2,
|
11
|
+
second_last: -1,
|
12
|
+
last: 0, # 0 - 1 will be -1 in ruby index
|
8
13
|
first: 1,
|
9
14
|
second: 2,
|
10
15
|
third: 3,
|
@@ -72,20 +77,17 @@ do |position, tag, attribute, attribute_value, seeable_content|
|
|
72
77
|
parent_el = find(:xpath, ".//tr[td[contains(text(), '#{seeable_content}')]]")
|
73
78
|
pos_number = @pos_number[position.to_sym]
|
74
79
|
|
75
|
-
|
76
|
-
#{tag}
|
77
|
-
[
|
78
|
-
[position()=#{pos_number}]")
|
79
|
-
el.click
|
80
|
+
els = all(:xpath, "#{parent_el.path}//\
|
81
|
+
#{tag}[contains(@#{attribute}, '#{attribute_value}')]")
|
82
|
+
els[pos_number - 1].click
|
80
83
|
end
|
81
84
|
|
82
85
|
# 2.7 Click on ordered element
|
83
86
|
When(/^I click on the ([^"]*) "([^"]*)" with attribute "([^"]*)" value \
|
84
87
|
"([^"]*)"/) do |position, tag, attribute, attribute_value|
|
85
88
|
pos_number = @pos_number[position.to_sym]
|
86
|
-
|
87
|
-
[
|
88
|
-
el.click
|
89
|
+
els = all(:xpath, ".//#{tag}[contains(@#{attribute}, '#{attribute_value}')]")
|
90
|
+
els[pos_number - 1].click
|
89
91
|
end
|
90
92
|
|
91
93
|
# 2.8 Click on a tag in the same box as something that I can see
|
@@ -101,11 +103,10 @@ box_attribute_name, box_attribute_value, seeable_content|
|
|
101
103
|
//*[contains(text(), '#{seeable_content}')]")
|
102
104
|
|
103
105
|
pos_number = @pos_number[position.to_sym]
|
104
|
-
|
106
|
+
els = all(:xpath, "#{parent_el.path}//\
|
105
107
|
#{tag}\
|
106
|
-
[contains(@#{attribute}, '#{attribute_value}')]
|
107
|
-
[
|
108
|
-
el.click
|
108
|
+
[contains(@#{attribute}, '#{attribute_value}')]")
|
109
|
+
els[pos_number - 1].click
|
109
110
|
end
|
110
111
|
|
111
112
|
# 2.9 Click on a special tag with text value
|
@@ -175,6 +176,23 @@ attribute "([^"]*)" value "([^"]*)"$/) do |option, attribute, value|
|
|
175
176
|
option.select_option
|
176
177
|
end
|
177
178
|
|
179
|
+
# 3.7a. Select an option from a dropdown with position box
|
180
|
+
# identified by attribute
|
181
|
+
When(/^I select "([^"]*)" from ([^"]+) drop down with \
|
182
|
+
attribute "([^"]*)" value "([^"]*)"$/) do |option, position, attribute, value|
|
183
|
+
selects = all(:xpath, ".//select[contains(@#{attribute}, '#{value}')]")
|
184
|
+
select = selects[@pos_number[position.to_sym] - 1]
|
185
|
+
|
186
|
+
if select.nil?
|
187
|
+
raise "No such select found with attribute \"#{attribute}\" ~= \"#{value}\""
|
188
|
+
end
|
189
|
+
|
190
|
+
option = select.find(:xpath, "option[contains(text(), '#{option}')]")
|
191
|
+
|
192
|
+
raise "No option found with text #{option}" if option.nil?
|
193
|
+
option.select_option
|
194
|
+
end
|
195
|
+
|
178
196
|
# 3.8 Select a date in date picker
|
179
197
|
# Use the command to fill in a text field
|
180
198
|
|
@@ -273,9 +291,11 @@ end
|
|
273
291
|
Then(/^(.*) within ([^"]*) "([^"]*)" with attribute "([^"]*)" value \
|
274
292
|
"([^"]*)"/) do |step, position, tag, attribute_name, attribute_value|
|
275
293
|
pos_number = @pos_number[position.to_sym]
|
276
|
-
|
277
|
-
|
278
|
-
[
|
294
|
+
els = all(:xpath,
|
295
|
+
".//#{tag}[contains(@#{attribute_name}, '#{attribute_value}')]")
|
296
|
+
el = els[pos_number - 1]
|
297
|
+
|
298
|
+
within(:xpath, el.path) do
|
279
299
|
step(step)
|
280
300
|
end
|
281
301
|
end
|
@@ -344,3 +364,8 @@ do |string, _tmp, format|
|
|
344
364
|
end
|
345
365
|
(Date.today - number.to_i.send(unit)).strftime(date_format)
|
346
366
|
end
|
367
|
+
|
368
|
+
Transform(/^(first|second|third|fourth|fifth) last$/) \
|
369
|
+
do |string|
|
370
|
+
"#{string}_last"
|
371
|
+
end
|
data/lib/cuke_master/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuke_master
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Huynh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|