bdd-helper 0.0.4 → 1.0.2
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 +5 -5
- data/lib/bdd-helper.rb +16 -9
- data/lib/demo.feature +172 -0
- data/lib/steps/action/check_steps.rb +19 -0
- data/lib/steps/action/choose_steps.rb +11 -0
- data/lib/steps/action/click_steps.rb +45 -0
- data/lib/steps/action/fill_steps.rb +85 -0
- data/lib/steps/action/key_action_steps.rb +59 -0
- data/lib/steps/action/select_steps.rb +24 -0
- data/lib/steps/assertion/assertion_steps.rb +314 -0
- data/lib/steps/config.rb +18 -3
- data/lib/steps/customized/customized_steps.rb +37 -0
- data/lib/steps/global/global_context.rb +9 -0
- data/lib/steps/util/browser_util_methods.rb +12 -0
- data/lib/steps/util/browser_util_steps.rb +202 -0
- data/lib/steps/util/fill_in_util.rb +11 -0
- metadata +54 -45
- data/lib/steps/assertion.rb +0 -92
- data/lib/steps/browser.rb +0 -35
- data/lib/steps/check.rb +0 -24
- data/lib/steps/click.rb +0 -26
- data/lib/steps/fill.rb +0 -44
- data/lib/steps/select.rb +0 -38
- data/lib/steps/unclassified.rb +0 -19
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bdd-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kloia
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -16,94 +16,104 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 2.11.0
|
19
|
+
version: '3.36'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 2.11.0
|
26
|
+
version: '3.36'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: cucumber
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 2.4.0
|
33
|
+
version: '7.1'
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
38
|
- - "~>"
|
48
39
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 2.4.0
|
40
|
+
version: '7.1'
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: rspec
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
56
44
|
requirements:
|
57
45
|
- - "~>"
|
58
46
|
- !ruby/object:Gem::Version
|
59
|
-
version: '3.
|
47
|
+
version: '3.10'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: selenium-webdriver
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
60
62
|
- - ">="
|
61
63
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
64
|
+
version: 4.0.3
|
63
65
|
type: :runtime
|
64
66
|
prerelease: false
|
65
67
|
version_requirements: !ruby/object:Gem::Requirement
|
66
68
|
requirements:
|
67
69
|
- - "~>"
|
68
70
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
71
|
+
version: '4.0'
|
70
72
|
- - ">="
|
71
73
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
74
|
+
version: 4.0.3
|
73
75
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
76
|
+
name: faker
|
75
77
|
requirement: !ruby/object:Gem::Requirement
|
76
78
|
requirements:
|
77
|
-
- -
|
79
|
+
- - "~>"
|
78
80
|
- !ruby/object:Gem::Version
|
79
|
-
version:
|
81
|
+
version: '2.19'
|
80
82
|
type: :runtime
|
81
83
|
prerelease: false
|
82
84
|
version_requirements: !ruby/object:Gem::Requirement
|
83
85
|
requirements:
|
84
|
-
- -
|
86
|
+
- - "~>"
|
85
87
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
87
|
-
description: Package of helper
|
88
|
-
email:
|
88
|
+
version: '2.19'
|
89
|
+
description: Package of helper steps for BDD testing with Cucumber
|
90
|
+
email: burak@kloia.com
|
89
91
|
executables: []
|
90
92
|
extensions: []
|
91
93
|
extra_rdoc_files: []
|
92
94
|
files:
|
93
95
|
- lib/bdd-helper.rb
|
94
|
-
- lib/
|
95
|
-
- lib/steps/
|
96
|
-
- lib/steps/
|
97
|
-
- lib/steps/
|
96
|
+
- lib/demo.feature
|
97
|
+
- lib/steps/action/check_steps.rb
|
98
|
+
- lib/steps/action/choose_steps.rb
|
99
|
+
- lib/steps/action/click_steps.rb
|
100
|
+
- lib/steps/action/fill_steps.rb
|
101
|
+
- lib/steps/action/key_action_steps.rb
|
102
|
+
- lib/steps/action/select_steps.rb
|
103
|
+
- lib/steps/assertion/assertion_steps.rb
|
98
104
|
- lib/steps/config.rb
|
99
|
-
- lib/steps/
|
100
|
-
- lib/steps/
|
101
|
-
- lib/steps/
|
102
|
-
|
105
|
+
- lib/steps/customized/customized_steps.rb
|
106
|
+
- lib/steps/global/global_context.rb
|
107
|
+
- lib/steps/util/browser_util_methods.rb
|
108
|
+
- lib/steps/util/browser_util_steps.rb
|
109
|
+
- lib/steps/util/fill_in_util.rb
|
110
|
+
homepage: https://github.com/kloia/bdd-helper
|
103
111
|
licenses:
|
104
112
|
- MIT
|
105
|
-
metadata:
|
106
|
-
|
113
|
+
metadata:
|
114
|
+
source_code_uri: https://github.com/kloia/bdd-helper
|
115
|
+
changelog_uri: https://github.com/kloia/bdd-helper/blob/master/CHANGELOG.md
|
116
|
+
post_install_message:
|
107
117
|
rdoc_options: []
|
108
118
|
require_paths:
|
109
119
|
- lib
|
@@ -111,16 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
121
|
requirements:
|
112
122
|
- - ">="
|
113
123
|
- !ruby/object:Gem::Version
|
114
|
-
version:
|
124
|
+
version: 2.6.0
|
115
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
126
|
requirements:
|
117
127
|
- - ">="
|
118
128
|
- !ruby/object:Gem::Version
|
119
129
|
version: '0'
|
120
130
|
requirements: []
|
121
|
-
|
122
|
-
|
123
|
-
signing_key:
|
131
|
+
rubygems_version: 3.2.32
|
132
|
+
signing_key:
|
124
133
|
specification_version: 4
|
125
|
-
summary: Helper
|
134
|
+
summary: Helper steps for client-based automation testing
|
126
135
|
test_files: []
|
data/lib/steps/assertion.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
require_relative 'config'
|
2
|
-
|
3
|
-
include BaseConstants
|
4
|
-
|
5
|
-
Then(/^page (should|should_not) contain "([^"]*)" content$/) do |condition, content|
|
6
|
-
# E.g. : page should contain "Test" content
|
7
|
-
# E.g. : page should_not contain "Test" content
|
8
|
-
# page.should have_content(content, count: count, wait: $timeout)
|
9
|
-
sleep 1
|
10
|
-
if condition == 'should'
|
11
|
-
page.should have_content(content, wait: $timeout)
|
12
|
-
|
13
|
-
elsif condition == 'should_not'
|
14
|
-
page.should_not have_content(content, wait: $timeout)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Then(/^page (should|should_not) contain the following contents:$/) do |condition, table|
|
19
|
-
sleep 1
|
20
|
-
values = table.raw
|
21
|
-
values.each {|raw|
|
22
|
-
if condition == 'should'
|
23
|
-
page.should have_content(raw[0], wait: $timeout)
|
24
|
-
elsif condition == 'should_not'
|
25
|
-
page.should_not have_content(raw[0], wait: $timeout)
|
26
|
-
end
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
Then(/^page (should|should_not) contain "([^"]*)" "([^"]*)" web element/) do |condition, web_element_type, web_element|
|
31
|
-
# E.g. : page should contain "css" "#test .form" web element
|
32
|
-
sleep 1
|
33
|
-
if condition == 'should'
|
34
|
-
page.should have_selector(:"#{web_element_type}", web_element, wait: $timeout)
|
35
|
-
|
36
|
-
elsif condition == 'should_not'
|
37
|
-
page.should_not have_selector(:"#{web_element_type}", web_element, wait: $timeout)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
Then(/^page (should|should_not) contain "([^"]*)" button$/) do |condition, button|
|
42
|
-
# E.g. : page should contain "Save" button
|
43
|
-
# E.g. : page should_not contain "Save" button
|
44
|
-
# page.should have_content(content, count: count, wait: $timeout)
|
45
|
-
sleep 1
|
46
|
-
if condition == 'should'
|
47
|
-
page.should have_button(button, wait: $timeout)
|
48
|
-
|
49
|
-
elsif condition == 'should_not'
|
50
|
-
page.should_not have_button(button, wait: $timeout)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
Then(/^"([^"]*)" button (should|should_not) be disabled$/) do |button, condition|
|
55
|
-
sleep 1
|
56
|
-
if condition == 'should'
|
57
|
-
find_button button, disabled: true
|
58
|
-
|
59
|
-
elsif condition == 'should_not'
|
60
|
-
find_button button, disabled: false
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
When(/^"([^"]*)" checkbox should be (checked|unchecked)$/) do |checkbox, condition|
|
65
|
-
# E.g. : "Agree" checkbox should be checked
|
66
|
-
# checkbox can be label, value or id
|
67
|
-
if condition == 'checked'
|
68
|
-
expect(page).to have_field(checkbox, checked: true, visible: true)
|
69
|
-
elsif condition == 'unchecked'
|
70
|
-
expect(page).to have_field(checkbox, checked: false, visible: true)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
When(/^"([^"]*)" radio button should be (selected|unselected)$/) do |radio_button, condition|
|
75
|
-
# E.g. : "Yes" radio button should be selected
|
76
|
-
# radio_button can be name, id or label
|
77
|
-
if condition == 'checked'
|
78
|
-
expect(page).to have_field(radio_button, checked: true, visible: true)
|
79
|
-
elsif condition == 'unchecked'
|
80
|
-
expect(page).to have_field(radio_button, checked: false, visible: true)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
Then(/^validation message should be "([^"]*)" about "([^"]*)" field$/) do |expected_message, element_value|
|
85
|
-
sleep 1.5
|
86
|
-
if page.has_css?(element_value)
|
87
|
-
expected_message.should == page.execute_script("return document.querySelector('#{element_value}').innerHTML.trim();")
|
88
|
-
|
89
|
-
elsif page.has_no_css?(element_value)
|
90
|
-
expected_message.should == ''
|
91
|
-
end
|
92
|
-
end
|
data/lib/steps/browser.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require_relative 'config'
|
2
|
-
|
3
|
-
include BaseConstants
|
4
|
-
|
5
|
-
And(/^refresh the page$/) do
|
6
|
-
page.evaluate_script('window.location.reload()')
|
7
|
-
sleep 1
|
8
|
-
end
|
9
|
-
|
10
|
-
When(/^navigate browser to "([^"]*)" url$/) do |url|
|
11
|
-
visit url
|
12
|
-
end
|
13
|
-
|
14
|
-
And(/^switch window to (first|last) opened$/) do |condition|
|
15
|
-
if condition == 'first'
|
16
|
-
page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
|
17
|
-
elsif condition == 'last'
|
18
|
-
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
Then(/^user should redirected to "([^"]*)" path$/) do |path|
|
23
|
-
page.should have_current_path(path, wait: $timeout)
|
24
|
-
end
|
25
|
-
|
26
|
-
Then(/^alert message (should|should_not) be "([^"]*)"$/) do |condition, message|
|
27
|
-
if condition == 'should'
|
28
|
-
resp = page.driver.browser.switch_to.alert.text
|
29
|
-
resp.should == message
|
30
|
-
|
31
|
-
elsif condition == 'should_not'
|
32
|
-
resp = page.driver.browser.switch_to.alert.text
|
33
|
-
resp.should_not == message
|
34
|
-
end
|
35
|
-
end
|
data/lib/steps/check.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'config'
|
2
|
-
|
3
|
-
include BaseConstants
|
4
|
-
|
5
|
-
When(/^(check|uncheck) "([^"]*)" checkbox$/) do |condition, checkbox|
|
6
|
-
# E.g. : check "Agree" checkbox
|
7
|
-
# checkbox can be name, id or label
|
8
|
-
if condition == 'check'
|
9
|
-
check(checkbox)
|
10
|
-
elsif condition == 'uncheck'
|
11
|
-
uncheck(checkbox)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
When(/^choose "([^"]*)" radio button$/) do |radio_button|
|
16
|
-
# E.g. : choose "Yes" radio button
|
17
|
-
# radio_button can be name, id or label
|
18
|
-
choose(radio_button)
|
19
|
-
end
|
20
|
-
|
21
|
-
And(/^check type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
|
22
|
-
page.should have_selector(:"#{web_element_type}", web_element, wait: $timeout)
|
23
|
-
find(:"#{web_element_type}", web_element).set(true)
|
24
|
-
end
|
data/lib/steps/click.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
When(/^click "([^"]*)" (link|button) by (id|title|text)$/) do |identifier, identifier_type, condition|
|
2
|
-
# E.g: click "Save" button by text
|
3
|
-
Capybara.ignore_hidden_elements = false
|
4
|
-
|
5
|
-
if condition == 'title' || condition == 'text'
|
6
|
-
page.should have_content(identifier)
|
7
|
-
|
8
|
-
elsif condition == 'id'
|
9
|
-
page.should have_selector(:id, identifier)
|
10
|
-
end
|
11
|
-
|
12
|
-
if identifier_type == 'link'
|
13
|
-
# link can be id, title or text
|
14
|
-
click_link(identifier)
|
15
|
-
|
16
|
-
elsif identifier_type == 'button'
|
17
|
-
# button can be id, title or text
|
18
|
-
click_button(identifier)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
Then(/^click type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
|
23
|
-
# E.g: click type "id" value "save" web element
|
24
|
-
page.should have_selector(:"#{web_element_type}", web_element)
|
25
|
-
find(:"#{web_element_type}", web_element).click
|
26
|
-
end
|
data/lib/steps/fill.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
require_relative 'config'
|
2
|
-
|
3
|
-
include BaseConstants
|
4
|
-
|
5
|
-
And(/^fill "([^"]*)" with "([^"]*)"$/) do |field, value|
|
6
|
-
# E.g : fill "Phone Number" with "5555555555"
|
7
|
-
# field can be name, id or label
|
8
|
-
fill_in(field, with: value)
|
9
|
-
end
|
10
|
-
|
11
|
-
And(/^fill input boxes with these values:$/) do |table|
|
12
|
-
values = table.raw
|
13
|
-
values.each {|raw| fill_in(raw[0], with: raw[1])}
|
14
|
-
end
|
15
|
-
|
16
|
-
Then(/^fill type "([^"]*)" value "([^"]*)" web element with "([^"]*)"$/) do |web_element_type, web_element, value|
|
17
|
-
# E.g: fill type "id" value "mobilePhone" web element with "5555555555"
|
18
|
-
page.should have_selector(:"#{web_element_type}", web_element, wait: $timeout)
|
19
|
-
find(:"#{web_element_type}", web_element).set(value)
|
20
|
-
end
|
21
|
-
|
22
|
-
And(/^fill "([^"]*)" with random (email|password|name|gsm)$/) do |field, condition|
|
23
|
-
def generate_code(number, condition)
|
24
|
-
if condition == 'email'
|
25
|
-
charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
|
26
|
-
Array.new(number) {charset.sample}.join + "@gmail.com"
|
27
|
-
|
28
|
-
elsif condition == 'password'
|
29
|
-
charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
|
30
|
-
Array.new(number) {charset.sample}.join
|
31
|
-
|
32
|
-
elsif condition == 'name'
|
33
|
-
charset = Array('A'..'Z') + Array('a'..'z')
|
34
|
-
Array.new(number) {charset.sample}.join
|
35
|
-
|
36
|
-
elsif condition == 'gsm'
|
37
|
-
charset = Array(0..9)
|
38
|
-
Array.new(7) {charset.sample}.join
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
var = generate_code(10, condition)
|
43
|
-
fill_in(field, with: var)
|
44
|
-
end
|
data/lib/steps/select.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
And(/^select "([^"]*)" as "([^"]*)" from dropdown$/) do |dropdown, option|
|
2
|
-
# E.g : select "Country" as "United States" from dropdown
|
3
|
-
# E.g : select "United States", from: "Country", :match => :first ===>> to select first matched option
|
4
|
-
# dropdown can be id, name, label text
|
5
|
-
select(option, from: dropdown) # OR ==>> find('#select_id').select('value')
|
6
|
-
end
|
7
|
-
|
8
|
-
Then /^"([^"]*)" (should|should_not) be selected for "([^"]*)" dropdown$/ do |selected_option, condition, dropdown|
|
9
|
-
# E.g : "United States" should be selected for "Country" dropdown
|
10
|
-
if condition == 'should'
|
11
|
-
page.should have_select(dropdown, selected: selected_option)
|
12
|
-
|
13
|
-
elsif condition == 'should_not'
|
14
|
-
page.should_not have_select(dropdown, selected: selected_option)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Then /^"([^"]*)" dropdown (should|should_not) contain "([^"]*)" option$/ do |dropdown, condition, option_text|
|
19
|
-
# E.g : "Country" dropdown should contain "United States" option
|
20
|
-
if condition == 'should'
|
21
|
-
page.should have_select(dropdown, with_options: [option_text])
|
22
|
-
|
23
|
-
elsif condition == 'should_not'
|
24
|
-
page.should_not have_select(dropdown, with_options: [option_text])
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
Then /^"([^"]*)" dropdown (should|should_not) contain following options:$/ do |dropdown, condition, table|
|
29
|
-
values = table.raw
|
30
|
-
sleep 1
|
31
|
-
values.each {|raw|
|
32
|
-
if condition == 'should'
|
33
|
-
page.should have_select(dropdown, with_options: [raw[0]])
|
34
|
-
|
35
|
-
elsif condition == 'should_not'
|
36
|
-
page.should_not have_select(dropdown, with_options: [raw[0]])
|
37
|
-
end}
|
38
|
-
end
|
data/lib/steps/unclassified.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
When(/^hover to "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
|
2
|
-
# E.g: hover to "css" value ".map" web element
|
3
|
-
find(:"#{web_element_type}", web_element).trigger(:mouseover)
|
4
|
-
end
|
5
|
-
|
6
|
-
When(/^wait "([^"]*)" seconds$/) do |sec_value|
|
7
|
-
sleep sec_value.to_i
|
8
|
-
end
|
9
|
-
|
10
|
-
And(/^generate "([^"]*)" char random string and type into type "([^"]*)" value "([^"]*)"$/) do |count, web_element_type, web_element|
|
11
|
-
# E.g: generate "10" char random string and type into type "id" value "mobile"
|
12
|
-
charset = (0...count).map {(65 + rand(26)).chr}.join
|
13
|
-
find(:"#{web_element_type}", web_element).set(charset)
|
14
|
-
end
|
15
|
-
|
16
|
-
And(/^execute javascript code "([^"]*)"/) do |code|
|
17
|
-
page.execute_script(code)
|
18
|
-
sleep 2
|
19
|
-
end
|