pickles 0.1.12 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/cucumber/pickles/config.rb +1 -1
- data/lib/cucumber/pickles/fill_in.rb +1 -0
- data/lib/cucumber/pickles/helpers/node_finders.rb +25 -0
- data/lib/cucumber/pickles/helpers/regex.rb +1 -1
- data/lib/cucumber/pickles/steps/can_see.rb +5 -3
- data/lib/cucumber/pickles/steps/fill.rb +5 -1
- data/lib/cucumber/pickles/steps/fill_in/js_select.rb +32 -0
- data/lib/cucumber/pickles/steps/fill_in/select.rb +8 -12
- data/lib/cucumber/pickles/steps/redirect.rb +6 -0
- data/lib/cucumber/pickles/transform.rb +0 -3
- data/lib/cucumber/pickles/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b246c85cb90145f058da79dac65a4826dce3c1f
|
4
|
+
data.tar.gz: ec1754a3f0fc0bb06c87624d76152a19afb4a5a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16ac3a5fb9385eb4278d1ca43ed330072e10438bde2779b23f43532e75dd77831802a9ff044f276c1f9241ef30611fb9128a7c33ee04fe5043c3d24fabe01d86
|
7
|
+
data.tar.gz: b6f4f774eadf120d651b9047d193b215734023f2aa29837884d5daddfac46797c6a27354980e34513cc0621c82eeb50681d8bf7e6a99d06161994f84af874014
|
@@ -22,7 +22,7 @@ class Pickles::Config
|
|
22
22
|
@css_node_map = {}
|
23
23
|
@log_xhr_response = false
|
24
24
|
@xpath_node_map = {}
|
25
|
-
@fill_tag_steps_map = { 'select' => FillIN::Select }
|
25
|
+
@fill_tag_steps_map = { 'select' => FillIN::Select, 'jselect' => FillIN::JsSelect }
|
26
26
|
@check_tag_steps_map = { 'text' => CheckIn::Text }
|
27
27
|
end
|
28
28
|
|
@@ -64,6 +64,31 @@ module NodeFinders
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
#
|
68
|
+
# try to guess which of the above 2 methods should be used
|
69
|
+
#
|
70
|
+
def guess_node(within_string, within: nil)
|
71
|
+
is_find_node_case = within_string[0] == "\"" && within_string[-1] == "\""
|
72
|
+
|
73
|
+
match = Helpers::Regex::WITHIN.match(within_string)
|
74
|
+
is_detect_node_case = !match.nil?
|
75
|
+
|
76
|
+
if is_detect_node_case
|
77
|
+
captures = match.captures
|
78
|
+
el_alias = captures[0]
|
79
|
+
locator = captures[1]
|
80
|
+
|
81
|
+
detect_node(el_alias, locator, within: within)
|
82
|
+
elsif is_find_node_case
|
83
|
+
within_string[0] = ''
|
84
|
+
within_string[-1] = ''
|
85
|
+
|
86
|
+
find_node(within_string, within: within)
|
87
|
+
else
|
88
|
+
fail "Incorrect within def"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
67
92
|
#
|
68
93
|
# Similar to find_node, but looking for fillable fields for this cases:
|
69
94
|
# 1. label or span(as label) with input hint for input || textarea || @contenteditable
|
@@ -5,16 +5,18 @@
|
|
5
5
|
# | .note | Nice guy |
|
6
6
|
#
|
7
7
|
|
8
|
-
Then(/^I can(not)? see
|
8
|
+
Then(/^I can(not)? see:( within (?:.*))?$/) do |is_not, within_block, table|
|
9
|
+
within_block ||= page
|
10
|
+
|
9
11
|
if is_not
|
10
12
|
check = -> within, content {
|
11
|
-
within = within.strip.present? ?
|
13
|
+
within = within.strip.present? ? Pickles.guess_node(within, within: within_block) : within_block
|
12
14
|
|
13
15
|
expect(within).not_to have_content(content)
|
14
16
|
}
|
15
17
|
else
|
16
18
|
check = -> within, content {
|
17
|
-
within = within.strip.present? ?
|
19
|
+
within = within.strip.present? ? Pickles.guess_node(within, within: within_block) : within_block
|
18
20
|
|
19
21
|
expect(within).to have_content(content)
|
20
22
|
}
|
@@ -61,7 +61,11 @@ When /^(?:|I )(fill|select)(?: "([^"]*)")?(?: with "([^"]*)")?( within (?:.*))?$
|
|
61
61
|
Waiter.wait_for_ajax
|
62
62
|
|
63
63
|
if type == 'select' && value.present?
|
64
|
-
|
64
|
+
begin
|
65
|
+
FillIN::Select.new(labels, value, within).call
|
66
|
+
rescue Capybara::ElementNotFound
|
67
|
+
FillIN::JsSelect.new(labels, value, within).call
|
68
|
+
end
|
65
69
|
else
|
66
70
|
labels.split(/\s*\|\s*/).each do |label|
|
67
71
|
FillIN::Factory.new(label, value, within: within).call.call
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class FillIN::JsSelect
|
2
|
+
|
3
|
+
def initialize(label, value, within)
|
4
|
+
@label = label
|
5
|
+
@value = value
|
6
|
+
@within = within || Capybara.current_session
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
input = FillIN::Input.new(@label, @value, @within).call
|
11
|
+
|
12
|
+
locator, index = Locator::Index.execute(@value)
|
13
|
+
locator, xpath = Locator::Equal.execute(locator)
|
14
|
+
|
15
|
+
index ||= 1
|
16
|
+
|
17
|
+
Waiter.wait do
|
18
|
+
input.find(:xpath, "./ancestor::*[#{xpath}][#{index}]/#{xpath}").click
|
19
|
+
end
|
20
|
+
|
21
|
+
Pickles.blur(input)
|
22
|
+
|
23
|
+
Waiter.wait_for_ajax
|
24
|
+
|
25
|
+
input
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :label, :value
|
31
|
+
|
32
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# When /^select "(.*)" from "(.*)"$/ do |value, label|
|
2
|
+
# select value, from: label
|
3
|
+
# end
|
4
|
+
|
1
5
|
class FillIN::Select
|
2
6
|
|
3
7
|
def initialize(label, value, within)
|
@@ -7,20 +11,12 @@ class FillIN::Select
|
|
7
11
|
end
|
8
12
|
|
9
13
|
def call
|
10
|
-
|
11
|
-
|
12
|
-
text, selector = NodeTextLookup.lookup_values(value)
|
13
|
-
item_xpath = selector.(text)
|
14
|
-
|
15
|
-
Waiter.wait do
|
16
|
-
input.find(:xpath, "./ancestor::*[#{item_xpath}][1]/#{item_xpath}").click
|
17
|
-
end
|
18
|
-
|
19
|
-
Pickles.blur(input)
|
14
|
+
locator, wait = Locator::Wait.execute(@label)
|
20
15
|
|
21
|
-
|
16
|
+
options = { from: locator }
|
17
|
+
options[:wait] = wait if wait
|
22
18
|
|
23
|
-
|
19
|
+
@within.select @value, options
|
24
20
|
end
|
25
21
|
|
26
22
|
private
|
@@ -1,9 +1,6 @@
|
|
1
|
-
within_reg = /\A\s*(.*)?\s*(?:["|'](.*?)["|'])?\s*\Z/
|
2
|
-
|
3
1
|
transformation = -> (within_info) do
|
4
2
|
splitted = within_info.split('within').reject(&:blank?)
|
5
3
|
|
6
|
-
|
7
4
|
splitted.reverse_each.inject(page) do |within, info|
|
8
5
|
captures = Helpers::Regex::WITHIN.match(info).captures
|
9
6
|
el_alias = captures[0]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pickles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/cucumber/pickles/steps/fill_in/complex_input.rb
|
115
115
|
- lib/cucumber/pickles/steps/fill_in/factory.rb
|
116
116
|
- lib/cucumber/pickles/steps/fill_in/input.rb
|
117
|
+
- lib/cucumber/pickles/steps/fill_in/js_select.rb
|
117
118
|
- lib/cucumber/pickles/steps/fill_in/select.rb
|
118
119
|
- lib/cucumber/pickles/steps/redirect.rb
|
119
120
|
- lib/cucumber/pickles/transform.rb
|