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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87108075b629af8a0a209c204d1d1f317c187897
4
- data.tar.gz: a876e27c0f8094ebbd36bad9975bc9e6bf79124c
3
+ metadata.gz: fb2250806db91cdb21f214bd0cb36c59893337a9
4
+ data.tar.gz: 30b89b34c02f1657e3fd594efe5e7efb82bd49da
5
5
  SHA512:
6
- metadata.gz: fd2d0f92cb67b8525fbc342de1f654671af7d142098859aaeea953147f91b7c7c04c1a1ec4fea70cfea52cdeb031953046e89f8441d1f7979e8f8d597d7ce340
7
- data.tar.gz: 2c74def24ca32dde798eeb39af1c4fdb3a68365ae30402641b98793971dd481d49764256b564e1ffb48f2091fb47b5f4610efdcf23ef96fd5e0ecb46eeb19ffc
6
+ metadata.gz: 0ec4276d601dcb77e8d88a118f5cbce34a02c20334ec37cb93b45e9ad9332cbdd259470856627993aeb6603794f8e530578e1f155d7413021cecb5aa93840418
7
+ data.tar.gz: 56ce9324c4a24dadb65c02f652f7eed06b1a18872ae6f56224be6771a1454912eb656b2479105079a01bb02c069d5918535fe4bf342f5728b3f547daf3298225
@@ -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
- el = first(:xpath, "#{parent_el.path}//\
76
- #{tag}\
77
- [contains(@#{attribute}, '#{attribute_value}')]\
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
- el = first(:xpath, ".//#{tag}[contains(@#{attribute}, '#{attribute_value}')]\
87
- [position()=#{pos_number}]")
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
- el = first(:xpath, "#{parent_el.path}//\
106
+ els = all(:xpath, "#{parent_el.path}//\
105
107
  #{tag}\
106
- [contains(@#{attribute}, '#{attribute_value}')]\
107
- [position()=#{pos_number}]")
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
- within(:xpath,
277
- ".//#{tag}[contains(@#{attribute_name}, '#{attribute_value}')]\
278
- [position()=#{pos_number}]") do
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
@@ -1,3 +1,3 @@
1
1
  module CukeMaster
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
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.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-17 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler