bdd-helper 0.0.4 → 1.0

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
- SHA1:
3
- metadata.gz: 6a9e8061724a7fb3583ee4a68f1ce2091760e3e7
4
- data.tar.gz: 146ed89fce2589ef73b93950869a76f1ad21233e
2
+ SHA256:
3
+ metadata.gz: 7a2f6404fb5d8c81b9e9537f34038036725ee9f8081cc336b6656efb23d14418
4
+ data.tar.gz: c219637921c7e57893839c417ee330a3dae119bc2363c518ca3cfe9373d842ed
5
5
  SHA512:
6
- metadata.gz: 40719aaef3cd0d06e955c4b5af1939bb7426ed425fc320b6164374b945708f0dbdab9770d8d999a2f35457798d01e4db94ddcf7e0007c39cb22faa2196debec3
7
- data.tar.gz: 1065251038130380666ef0a5a24d5b6e2a84a2ccecc87cb331a6bef9a4310b4bae48be01ef1f3b9dc8000aea387613d38fc1b8ede5871778fb62a3f04906db4c
6
+ metadata.gz: 1f03a9b36f0e1e47104df4672db7295f24a66832c184478468cf3f15bcc66a9daaf0d44e5f89227e4187df7215f1dbed5f30ca2671bbc1704afbb5a134d44de7
7
+ data.tar.gz: 9739cee85ca0997bafa0e52ddd0da7c111bbbc7a894e608ba267f80c90448d91a1aa9f2d1ea8b6174752a4be38741a5f17b779656026e5f59f74913d8ac690b3
data/lib/bdd-helper.rb CHANGED
@@ -1,17 +1,23 @@
1
1
  require 'capybara'
2
- require 'capybara/cucumber'
3
- require 'capybara/dsl'
4
2
  require 'capybara/rspec'
5
3
  require 'rspec'
6
4
  require 'rspec/expectations'
7
5
  require 'rspec/matchers'
8
6
  require 'selenium/webdriver'
9
7
  require 'selenium/webdriver/common/wait'
8
+ require 'faker'
10
9
 
11
- require 'steps/assertion'
12
- require 'steps/browser'
13
- require 'steps/check'
14
- require 'steps/click'
15
- require 'steps/fill'
16
- require 'steps/select'
17
- require 'steps/unclassified'
10
+
11
+ require 'steps/action/check_steps'
12
+ require 'steps/action/choose_steps'
13
+ require 'steps/action/click_steps'
14
+ require 'steps/action/fill_steps'
15
+ require 'steps/action/key_action_steps'
16
+ require 'steps/action/select_steps'
17
+ require 'steps/assertion/assertion_steps'
18
+ require 'steps/customized/customized_steps'
19
+ require 'steps/util/browser_util_steps'
20
+ require 'steps/util/browser_util_methods'
21
+ require 'steps/config'
22
+ require 'steps/global/global_context'
23
+ require 'steps/config'
data/lib/demo.feature ADDED
@@ -0,0 +1,141 @@
1
+ Feature: demo features
2
+
3
+
4
+ Scenario: steps
5
+ ####################################
6
+ # BROWSER UTIL
7
+ When visit base page
8
+ When visit "http://www.example.com" url
9
+ When get current url
10
+ When get window title
11
+
12
+ When scroll top of the page
13
+ When scroll bottom of the page
14
+ When scroll 250 px up the page
15
+ When scroll 250 px down the page
16
+
17
+ When focus to element by "Agree Button" text
18
+
19
+ When go back
20
+ When go forward
21
+ When refresh the page
22
+
23
+ When accept alert
24
+ When dismiss alert
25
+
26
+ When open a new window
27
+ When switch to first window
28
+ When switch to last window
29
+ When switch to first window
30
+ When open a new tab
31
+ When switch to first tab
32
+ When switch to last tab
33
+ When switch to window by "Welcome" title
34
+
35
+ When close window
36
+ When maximize window
37
+ When get window size
38
+ When resize window to 123 width 123 height
39
+ # BROWSER UTIL
40
+ ####################################
41
+
42
+ ########################################################################
43
+
44
+ ####################################
45
+ # ASSERTION
46
+ Then verify below texts are displayed:
47
+ | Welcome |
48
+ | Thank you |
49
+ Then verify below texts are not displayed:
50
+ | Welcome |
51
+ | Thank you |
52
+ Then verify "text" text is displayed
53
+ Then verify "text" text is not displayed
54
+
55
+
56
+ Then verify ".success-message" element has "Welcome" text
57
+ Then verify ".fail-message" element has not "Welcome" text
58
+
59
+ Then verify "Login" button is displayed
60
+ Then verify "Sign In " button is not displayed
61
+
62
+ Then verify "Login" button is enabled
63
+ Then verify "Logout" button is disabled
64
+
65
+ Then verify current url is "http:www.example.com"
66
+ Then verify current path is "/login"
67
+
68
+ Then verify page title is "Welcome"
69
+ Then verify page title contains "Welcome"
70
+
71
+ Then verify "Successful Login" alert message is displayed
72
+ Then verify "Incorrect login or password." alert message is not displayed
73
+
74
+
75
+ Then verify "Terms & Conditions" checkbox is checked
76
+ Then verify "Terms & Conditions" checkbox is unchecked
77
+
78
+ Then verify "Male" radio button is selected
79
+ Then verify "Female" radio button is not selected
80
+ Then verify "cars" dropdown contains "audi" option
81
+ Then verify "cars" dropdown does not contain "audi" option
82
+ Then verify "cars" dropdown contains the options below:
83
+ | au |
84
+ | bm |
85
+
86
+ Then verify "audi" options is selected from "cars" dropdown
87
+ Then verify "audi" options is not selected from "cars" dropdown
88
+ # ASSERTION
89
+ ####################################
90
+
91
+ ########################################################################
92
+
93
+ ####################################
94
+ # ACTION
95
+ When fill "Username" with "value"
96
+ When fill "First Name" with random first name
97
+ When fill "Last Name" with random last name
98
+ When fill "Email" with random email
99
+ When fill "Phone Number" with random phone number
100
+ When fill "Address" with random address
101
+ When fill "Zip Code" with random zip code
102
+
103
+ When fill inputs:
104
+ | username | test user |
105
+ | password | pas123 |
106
+
107
+ When click "Contact Us" link
108
+ When click "Sign In" button
109
+
110
+ When check "Terms & Conditions" checkbox
111
+ When uncheck "Privacy Policy" checkbox
112
+
113
+ When choose "Male" radio button
114
+
115
+ When clear "First Name" input
116
+ When select "audi" from "cars" dropdown
117
+
118
+ When press "#login" enter
119
+ When press "#username" delete
120
+ When press ".list-selector" down
121
+ When press ".list-selector" up
122
+ When press ".list-selector" left
123
+ When press ".list-selector" right
124
+
125
+ When click "Logout" under ".account-menu"
126
+ When click "Logout" item 0 under ".account-menu" menu item 0
127
+
128
+ When hover over "Account"
129
+ # ACTION
130
+ ####################################
131
+
132
+ ########################################################################
133
+
134
+ ####################################
135
+ # CUSTOMIZED
136
+ When hover to "css" value ".list_item" web element
137
+ When wait 2 seconds
138
+ When generate 10 char random string and type into type "css" value ".username"
139
+ When execute javascript code "window.location.reload()"
140
+ # CUSTOMIZED
141
+ ####################################
@@ -0,0 +1,19 @@
1
+ begin
2
+ When(/^check "([^"]*)" checkbox$/) do |checkbox_name_id_or_label|
3
+ "
4
+ Checkbox can be name, id and label text
5
+ "
6
+ # E.g : And check "Terms & Conditions" checkbox
7
+ check(checkbox_name_id_or_label, wait: BddHelper.timeout)
8
+ end
9
+
10
+ When(/^uncheck "([^"]*)" checkbox$/) do |checkbox_name_id_or_label|
11
+ "
12
+ Checkbox can be name, id and label text
13
+ "
14
+ # E.g : And uncheck "Privacy Policy" checkbox
15
+ uncheck(checkbox_name_id_or_label, wait: BddHelper.timeout)
16
+ end
17
+ rescue StandardError => e
18
+ puts e
19
+ end
@@ -0,0 +1,11 @@
1
+ begin
2
+ When(/^choose "([^"]*)" radio button$/) do |radio_button_id_name_or_label|
3
+ "
4
+ Radio Button can be name, id and label text
5
+ "
6
+ # E.g : And choose "Male" radio button
7
+ choose(radio_button_id_name_or_label, wait: BddHelper.timeout)
8
+ end
9
+ rescue StandardError => e
10
+ puts e
11
+ end
@@ -0,0 +1,37 @@
1
+ begin
2
+ When(/^click "([^"]*)" button$/) do |button_id_title_or_text|
3
+ "
4
+ Button can be name, id, value or title
5
+ "
6
+ # E.g : And click "Sign In" button
7
+ click_button(button_id_title_or_text, wait: BddHelper.timeout)
8
+ end
9
+
10
+ When(/^click "([^"]*)" link$/) do |link_id_title_or_text|
11
+ "
12
+ Link can be id, text or title
13
+ "
14
+ # E.g : And click "Contact Us" link
15
+ click_link(link_id_title_or_text, wait: BddHelper.timeout)
16
+ end
17
+
18
+ When(/^click "([^"]*)" under "([^"]*)"$/) do |link, menu|
19
+ "
20
+ Finds a element with capybara default_selector, link can be id, text or title
21
+ "
22
+ # E.g : And click "Logout" under ".account-menu"
23
+ find(menu, wait: BddHelper.timeout).hover
24
+ click_link(link, wait: BddHelper.timeout)
25
+ end
26
+
27
+ When(/^click "([^"]*)" item (\d+) under "([^"]*)" menu item (\d+)$/) do |link, link_item, menu, menu_item|
28
+ "
29
+ Link can be id, text or title, menu can be text content
30
+ "
31
+ # E.g : And click "Logout" item 2 under "Account" menu item 1
32
+ (page.all(:xpath, "//*[text()='#{menu}']", wait: BddHelper.timeout)[menu_item]).hover
33
+ (page.all(:link, link, wait: BddHelper.timeout)[link_item]).click
34
+ end
35
+ rescue StandardError => e
36
+ puts e
37
+ end
@@ -0,0 +1,77 @@
1
+ begin
2
+ When(/^fill "([^"]*)" with "([^"]*)"$/) do |locator, text|
3
+ "
4
+ Fillable field can be name, id, placeholder or label text
5
+ "
6
+ # E.g : And fill "Name" with "John"
7
+ fill_in(locator, with: text, wait: BddHelper.timeout)
8
+ end
9
+
10
+ When(/^fill inputs:$/) do |table|
11
+ "
12
+ Fillable field can be name, id, placeholder or label text
13
+ "
14
+ # E.g : And fill inputs:
15
+ # | username | test user |
16
+ # | password | pass123 |
17
+ table.raw.each { |raw| fill_in(raw[0], with: raw[1], wait: BddHelper.timeout) }
18
+ end
19
+
20
+ When(/^fill "([^"]*)" with random (first name)$/) do |locator, arg|
21
+ "
22
+ Fillable field can be name, id, placeholder or label text
23
+ "
24
+ # E.g : And fill "First Name" with random first name
25
+ fill_in(locator, with: Faker::Name.first_name, wait: BddHelper.timeout)
26
+ end
27
+
28
+ When(/^fill "([^"]*)" with random (last name)$/) do |locator, arg|
29
+ "
30
+ Fillable field can be name, id, placeholder or label text
31
+ "
32
+ # E.g : And fill "Last Name" with random last name
33
+ fill_in(locator, with: Faker::Name.last_name, wait: BddHelper.timeout)
34
+ end
35
+
36
+ When(/^fill "([^"]*)" with random (email)$/) do |locator, arg|
37
+ "
38
+ Fillable field can be name, id, placeholder or label text
39
+ "
40
+ # E.g : And fill "Email" with random email
41
+ fill_in(locator, with: Faker::Internet.safe_email, wait: BddHelper.timeout)
42
+ end
43
+
44
+ When(/^fill "([^"]*)" with random (phone number)$/) do |locator, arg|
45
+ "
46
+ Fillable field can be name, id, placeholder or label text
47
+ "
48
+ # E.g : And fill "Phone Number" with random phone number
49
+ fill_in(locator, with: Array.new(7) { Array(0..9).sample }.join, wait: BddHelper.timeout)
50
+ end
51
+
52
+ When(/^fill "([^"]*)" with random (address)$/) do |locator, arg|
53
+ "
54
+ Fillable field can be name, id, placeholder or label text
55
+ "
56
+ # E.g : And fill "Address" with random address
57
+ fill_in(locator, with: Faker::Address.full_address, wait: BddHelper.timeout)
58
+ end
59
+
60
+ When(/^fill "([^"]*)" with random (zip code)$/) do |locator, arg|
61
+ "
62
+ Fillable field can be name, id, placeholder or label text
63
+ "
64
+ # E.g : And fill "Zip Code" with random zip code
65
+ fill_in(locator, with: Faker::Address.zip_code, wait: BddHelper.timeout)
66
+ end
67
+
68
+ When(/^clear "([^"]*)" input$/) do |locator|
69
+ "
70
+ Fillable field can be name, id, placeholder or label text
71
+ "
72
+ # E.g : And clear "Name" input
73
+ fill_in(locator, with: '', fill_options: { clear: :backspace }, wait: BddHelper.timeout)
74
+ end
75
+ rescue StandardError => e
76
+ puts e
77
+ end
@@ -0,0 +1,59 @@
1
+ begin
2
+ When(/^press "([^"]*)" (enter)$/) do |locator, arg|
3
+ "
4
+ Locator should be capybara default_selector
5
+ "
6
+ # E.g : And press "#login" enter
7
+ find(locator, wait: BddHelper.timeout).native.send_keys(:return)
8
+ end
9
+
10
+ When(/^press "([^"]*)" (down)$/) do |locator, arg|
11
+ "
12
+ Locator should be capybara default_selector
13
+ "
14
+ # E.g : And press ".list-selector" down
15
+ find(locator, wait: BddHelper.timeout).native.send_keys(:down)
16
+ end
17
+
18
+ When(/^press "([^"]*)" (up)$/) do |locator, arg|
19
+ "
20
+ Locator should be capybara default_selector
21
+ "
22
+ # E.g : And press ".list-selector" up
23
+ find(locator, wait: BddHelper.timeout).native.send_keys(:up)
24
+ end
25
+
26
+ When(/^press "([^"]*)" (delete)$/) do |locator, arg|
27
+ "
28
+ Locator should be capybara default_selector
29
+ "
30
+ # E.g : And press "#username" delete
31
+ find(locator, wait: BddHelper.timeout).native.clear
32
+ end
33
+
34
+ When(/^press "([^"]*)" (left)$/) do |locator, arg|
35
+ "
36
+ Locator should be capybara default_selector
37
+ "
38
+ # E.g : And press ".list-selector" left
39
+ find(locator, wait: BddHelper.timeout).native.send_keys(:left)
40
+ end
41
+
42
+ When(/^press "([^"]*)" (right)$/) do |locator, arg|
43
+ "
44
+ Locator should be capybara default_selector
45
+ "
46
+ # E.g : And press ".list-selector" right
47
+ find(locator, wait: BddHelper.timeout).native.send_keys(:right)
48
+ end
49
+
50
+ When(/^hover over "([^"]*)"$/) do |text|
51
+ # E.g : And hover over "Account"
52
+ find(:xpath, "//*[text()='#{text}']", wait: BddHelper.timeout).hover
53
+ end
54
+
55
+ rescue StandardError => e
56
+ puts e
57
+
58
+ end
59
+
@@ -0,0 +1,16 @@
1
+ begin
2
+ When(/^select "([^"]*)" from "([^"]*)" dropdown$/) do |option, dropdown_id_name_or_label_text|
3
+ "
4
+ Dropdown can be id, name, label
5
+ "
6
+ # E.g : And select "United States" from "Country" dropdown
7
+ unless has_select?(dropdown_id_name_or_label_text)
8
+ raise "#{dropdown_id_name_or_label_text} is not a select box."
9
+ end
10
+ select(option, from: dropdown_id_name_or_label_text, wait: BddHelper.timeout)
11
+ page.should have_select(dropdown_id_name_or_label_text, selected: option)
12
+ end
13
+
14
+ rescue StandardError => e
15
+ puts e
16
+ end
@@ -0,0 +1,202 @@
1
+ # frozen_string = true
2
+ begin
3
+ Then(/^verify "([^"]*)" text is displayed$/) do |text|
4
+ # E.g : Then verify "Thank you for filling in the form" text is displayed
5
+ page.should have_text(text, wait: BddHelper.timeout)
6
+ end
7
+
8
+ Then(/^verify "([^"]*)" text is not displayed$/) do |text|
9
+ # E.g : Then verify "Thank you for filling in the form" text is not displayed
10
+ page.should_not have_text(text, wait: BddHelper.timeout)
11
+ end
12
+
13
+ Then(/^verify "([^"]*)" element has "([^"]*)" text$/) do |selector, text|
14
+ "
15
+ Selector should be a css selector
16
+ "
17
+ # E.g : Then verify ".success-message" element has "Welcome" text
18
+ page.should have_selector(selector, text: text, wait: BddHelper.timeout)
19
+ end
20
+
21
+ Then(/^verify "([^"]*)" element has not "([^"]*)" text$/) do |selector, text|
22
+ "
23
+ Selector should be a css selector
24
+ "
25
+ # E.g : Then verify ".success-message" element has not "Welcome" text
26
+ page.should_not have_selector(selector, text: text, wait: BddHelper.timeout)
27
+ end
28
+
29
+ Then(/^verify "([^"]*)" button is displayed$/) do |button|
30
+ "
31
+ Button can be id, name, value, or title
32
+ "
33
+ # E.g : Then verify "Login" button is displayed
34
+ page.should have_button(button, wait: BddHelper.timeout)
35
+ end
36
+
37
+ Then(/^verify "([^"]*)" button is not displayed$/) do |button|
38
+ "
39
+ Button can be id, name, value, or title
40
+ "
41
+ # E.g : Then verify "Login" button is not displayed
42
+ page.should_not have_button(button, wait: BddHelper.timeout)
43
+ end
44
+
45
+ Then(/^verify "([^"]*)" button is enabled$/) do |button|
46
+ "
47
+ Button can be id, name, value, or title
48
+ "
49
+ # E.g : Then verify "Login" button is enabled
50
+ page.should have_button(button, disabled: false, wait: BddHelper.timeout)
51
+ end
52
+
53
+ Then(/^verify "([^"]*)" button is disabled$/) do |button|
54
+ "
55
+ Button can be id, name, value, or title
56
+ "
57
+ # E.g : Then verify "Login" button is disabled
58
+ page.should have_button(button, disabled: true, wait: BddHelper.timeout)
59
+ end
60
+
61
+ Then(/^verify current url is "([^"]*)"$/) do |expected_url|
62
+ "
63
+ Expected url should be fully URL of the current page
64
+ "
65
+ # E.g : Then verify current url is "http:www.example.com"
66
+ current_url.should == expected_url
67
+ end
68
+
69
+ Then(/^verify current path is "([^"]*)"$/) do |current_path|
70
+ "
71
+ Path should be path+query of the current page
72
+ "
73
+ # E.g : Then verify current path is "/login"
74
+ assert_current_path(current_path)
75
+ end
76
+
77
+ Then(/^verify page title is "([^"]*)"$/) do |page_title|
78
+ "
79
+ Title should be title of the current page
80
+ "
81
+ # E.g : Then verify page title is "Welcome"
82
+ assert_title(page_title, wait: BddHelper.timeout)
83
+ end
84
+
85
+ Then(/^verify page title contains "([^"]*)"$/) do |text|
86
+ "
87
+ Title should be contains of the current page title
88
+ "
89
+ # E.g : Then verify page title contains "Welcome"
90
+ title.should include(text)
91
+ end
92
+
93
+ Then(/^verify below texts are displayed:$/) do |table|
94
+ # E.g : Then verify below texts are displayed:
95
+ # | Welcome |
96
+ # | Thank you |
97
+ table.raw.each { |raw| page.should have_text(raw[0], wait: BddHelper.timeout) }
98
+ end
99
+
100
+ Then(/^verify below texts are not displayed:$/) do |table|
101
+ # E.g : Then verify below texts are not displayed:
102
+ # | Welcome |
103
+ # | Thank you |
104
+ table.raw.each { |raw| page.should_not have_text(raw[0], wait: BddHelper.timeout) }
105
+ end
106
+
107
+ Then(/^verify "([^"]*)" alert message is displayed$/) do |text|
108
+ # E.g : Then verify "Successful" alert message is displayed
109
+ text.should == page.driver.browser.switch_to.alert.text
110
+ end
111
+
112
+ Then(/^verify "([^"]*)" alert message is not displayed$/) do |text|
113
+ # E.g : Then verify "Successful" alert message is not displayed
114
+ text.should_not == page.driver.browser.switch_to.alert.text
115
+ end
116
+
117
+ Then(/^verify "([^"]*)" checkbox is checked$/) do |checkbox|
118
+ "
119
+ Checkbox can be name, id and label text
120
+ "
121
+ # E.g : Then verify "Terms & Conditions" checkbox is checked
122
+ expect(page).to have_field(checkbox, checked: true, visible: true, wait: BddHelper.timeout)
123
+ end
124
+
125
+ Then(/^verify "([^"]*)" checkbox is unchecked/) do |checkbox|
126
+ "
127
+ Checkbox can be name, id and label text
128
+ "
129
+ # E.g : Then verify "Terms & Conditions" checkbox is unchecked
130
+ expect(page).to have_field(checkbox, checked: false, visible: true, wait: BddHelper.timeout)
131
+ end
132
+
133
+ Then(/^verify "([^"]*)" radio button is selected$/) do |radio_button|
134
+ "
135
+ Radio Button can be name, id and label text
136
+ "
137
+ # E.g : Then verify "Male" radio button is selected
138
+ expect(page).to have_field(radio_button, checked: true, visible: true, wait: BddHelper.timeout)
139
+ end
140
+
141
+ Then(/^verify "([^"]*)" radio button is not selected$/) do |radio_button|
142
+ "
143
+ Radio Button can be name, id and label text
144
+ "
145
+ # E.g : Then verify "Female" radio button is not selected
146
+ expect(page).to have_field(radio_button, checked: false, visible: true, wait: BddHelper.timeout)
147
+ end
148
+
149
+ Then(/^verify "([^"]*)" dropdown contains "([^"]*)" option$/) do |dropdown, option_text|
150
+ "
151
+ Dropdown can be id, name, label
152
+ "
153
+ # E.g : Then verify "Country" dropdown contains "United States" option
154
+ page.should have_select(dropdown, with_options: [option_text], wait: BddHelper.timeout)
155
+ end
156
+
157
+ Then(/^verify "([^"]*)" dropdown does not contain "([^"]*)" option$/) do |dropdown, option_text|
158
+ "
159
+ Dropdown can be id, name, label
160
+ "
161
+ # E.g : Then verify "Country" dropdown does not contain "United States" option
162
+ page.should_not have_select(dropdown, with_options: [option_text], wait: BddHelper.timeout)
163
+ end
164
+
165
+ Then(/^verify "([^"]*)" dropdown contains the options below:$/) do |dropdown, table|
166
+ "
167
+ Dropdown can be id, name, label
168
+ "
169
+ # E.g : Then verify "Country" dropdown contains the options below:
170
+ # |United States|
171
+ # |Turkey |
172
+ table.raw.each { |raw| page.should have_select(dropdown, with_options: [raw[0]], wait: BddHelper.timeout) }
173
+ end
174
+
175
+ Then(/^verify "([^"]*)" dropdown does not contain the options below:$/) do |dropdown, table|
176
+ "
177
+ Dropdown can be id, name, label
178
+ "
179
+ # E.g : Then verify "Country" dropdown does not contain the options below:
180
+ # |United States|
181
+ # |Turkey |
182
+ table.raw.each { |raw| page.should_not have_select(dropdown, with_options: [raw[0]], wait: BddHelper.timeout) }
183
+ end
184
+
185
+ Then(/^verify "([^"]*)" options is selected from "([^"]*)" dropdown$/) do |option, dropdown|
186
+ "
187
+ Dropdown can be id, name, label
188
+ "
189
+ # E.g : Then verify "United States" options is selected from "Country" dropdown
190
+ page.should have_select(dropdown, selected: option, wait: BddHelper.timeout)
191
+ end
192
+
193
+ Then(/^verify "([^"]*)" options is not selected from "([^"]*)" dropdown$/) do |option, dropdown|
194
+ "
195
+ Dropdown can be id, name, label
196
+ "
197
+ # E.g : Then verify "United States" options is not selected from "Country" dropdown
198
+ page.should_not have_select(dropdown, selected: option, wait: BddHelper.timeout)
199
+ end
200
+ rescue StandardError => e
201
+ puts e
202
+ end
data/lib/steps/config.rb CHANGED
@@ -1,5 +1,20 @@
1
- module BaseConstants
1
+ module BddHelper
2
+ class << self
3
+ attr_accessor :timeout, :base_url
2
4
 
3
- $timeout = 20
5
+ def timeout
6
+ @timeout || 20
7
+ end
4
8
 
5
- end
9
+ def base_url
10
+ unless @base_url.nil? || @base_url.match?(URI::DEFAULT_PARSER.make_regexp)
11
+ raise ArgumentError, "BddHelper.base_url should be set to a url (http://www.example.com). Attempted to set #{@base_url.inspect}."
12
+ end
13
+ @base_url || nil
14
+ end
15
+
16
+ def configure
17
+ yield self
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ begin
2
+ When(/^hover to "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
3
+ "
4
+ Web element type can be css, xpath, id, field, link, button, link_or_button or label
5
+ "
6
+ # E.g: And hover to "css" value ".list_item" web element
7
+ find(:"#{web_element_type}".to_sym, web_element).hover
8
+ end
9
+
10
+ When(/^wait (\d+) (?:second|seconds)$/) do |sec_value|
11
+ "
12
+ Second's value should be integer
13
+ "
14
+ # E.g: And wait 2 seconds
15
+ sleep sec_value.to_i
16
+ end
17
+
18
+ And(/^generate (\d+) char random string and type into type "([^"]*)" value "([^"]*)"$/) do |count, web_element_type, web_element|
19
+ "
20
+ Web element type can be css, xpath, id, field, fillable_field or label
21
+ "
22
+ # E.g: And generate "10" char random string and type into type "id" value "mobile"
23
+ charset = (0...count).map { rand(65..90).chr }.join
24
+ find(:"#{web_element_type}".to_sym, web_element, wait: BddHelper.timeout).set(charset)
25
+ end
26
+
27
+ And(/^execute javascript code "([^"]*)"/) do |code|
28
+ "
29
+ Code should be javascript code
30
+ "
31
+ # E.g : And execute javascript code "window.location.reload()"
32
+ page.execute_script(code)
33
+ end
34
+
35
+ rescue StandardError => e
36
+ puts e
37
+ end
@@ -0,0 +1,9 @@
1
+ class GlobalContext
2
+
3
+ # Resets global variables for each scenario in an execution
4
+ def initialize
5
+ $page_title = nil
6
+ $current_url = nil
7
+ $window_size =nil
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ class BrowserUtilMethods
2
+
3
+ def scroll_to(element)
4
+ script = <<-JS
5
+ arguments[0].scrollIntoView(true);
6
+ JS
7
+ page.execute_script(script, element.native)
8
+ end
9
+
10
+ rescue StandardError => e
11
+ puts e
12
+ end
@@ -0,0 +1,178 @@
1
+ begin
2
+ When(/^scroll (\d+) px (down) the page$/) do |pixel, arg|
3
+ "
4
+ This scrolls down the page by the given amount of pixel.
5
+ "
6
+ # E.g : And scroll 500 px down the page
7
+ page.execute_script("window.scrollBy(0,#{pixel})")
8
+ end
9
+
10
+ When(/^scroll (\d+) px (up) the page$/) do |pixel, arg|
11
+ "
12
+ This scrolls up the page by the given amount of pixel.
13
+ "
14
+ # E.g : And scroll 500 px up the page
15
+ page.execute_script("window.scrollBy(0,#{-pixel})")
16
+ end
17
+
18
+ When(/^scroll (bottom) of the page$/) do |arg|
19
+ "
20
+ This scrolls the page to the bottom
21
+ "
22
+ # E.g : And scroll bottom of the page
23
+ page.execute_script('window.scrollTo(0, document.body.scrollHeight)')
24
+ end
25
+
26
+ When(/^scroll (top) of the page$/) do |arg|
27
+ "
28
+ This scrolls the page to the top
29
+ "
30
+ # E.g : And scroll top of the page
31
+ page.execute_script('window.scrollTo(document.body.scrollHeight,0)')
32
+ end
33
+
34
+ When(/^focus to element by "([^"]*)" text$/) do |text|
35
+ # E.g : And focus to element by "Agree Button" text
36
+ scroll_to(find(xpath: "//*[contains(text(), '#{text}')]"))
37
+ end
38
+
39
+ When(/^refresh the page$/) do
40
+ "
41
+ This refreshes the current page
42
+ "
43
+ # E.g : And refresh the page
44
+ page.evaluate_script('window.location.reload()')
45
+ end
46
+
47
+ When(/^open a (new window)$/) do |args|
48
+ # E.g : And open a new window
49
+ open_new_window(:window)
50
+ end
51
+
52
+ When(/^open a (new tab)$/) do |args|
53
+ # E.g : And open a new tab
54
+ open_new_window
55
+ end
56
+
57
+ When(/^switch to (last window|last tab)$/) do |arg|
58
+ # E.g : And switch to last window
59
+ # E.g : And switch to last tab
60
+ page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
61
+ end
62
+
63
+ When(/^switch to (first window|first tab)$/) do |arg|
64
+ # E.g : And switch to first window
65
+ # E.g : And switch to first tab
66
+ page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
67
+ end
68
+
69
+ When(/^switch to window by "([^"]*)" title$/) do |window_title|
70
+ "
71
+ Window title should be title of the target window
72
+ "
73
+ # E.g : And switch to window by "Welcome" title
74
+ switch_to_window { title == window_title }
75
+ end
76
+
77
+ When(/^resize window to (\d+) width (\d+) height$/) do |width, height|
78
+ "
79
+ This resize to the current window by the given width and height
80
+ "
81
+ # E.g : And resize window to 1280 width 720 height
82
+ page.driver.browser.manage.window.resize_to(width, height)
83
+ end
84
+
85
+ When(/^get window size$/) do
86
+ "
87
+ This gets the current window's size then defines it to the global variable
88
+ "
89
+ # E.g : And get window size
90
+ $window_size = page.driver.browser.manage.window.size
91
+ end
92
+
93
+ When(/^close window$/) do
94
+ "
95
+ This closes the current window
96
+ "
97
+ # E.g : And close window
98
+ page.driver.browser.close
99
+ end
100
+
101
+ When(/^get current url$/) do
102
+ "
103
+ This get full URL of the current page then defines it to the global variable
104
+ "
105
+ # E.g : And get current url
106
+ $current_url = current_url
107
+ end
108
+
109
+ When(/^go back$/) do
110
+ "
111
+ This move back a single entry in the browser's history
112
+ "
113
+ # E.g : And go back
114
+ go_back
115
+ end
116
+
117
+ When(/^go forward$/) do
118
+ "
119
+ This move forward a single entry in the browser's history
120
+ "
121
+ # E.g : And go forward
122
+ go_forward
123
+ end
124
+
125
+ When(/^visit base page$/) do
126
+ "
127
+ Should configure base_url from bdd-helper config
128
+ "
129
+ # E.g : And visit base page
130
+ visit BddHelper.base_url
131
+ end
132
+
133
+ When(/^visit "([^"]*)" url$/) do |url|
134
+ "
135
+ The URL can either be a relative URL or an absolute URL
136
+ "
137
+ # E.g : And visit "http://www.example.com" url
138
+ visit url
139
+ end
140
+
141
+ When(/^visit relative url "([^"]*)"$/) do |url|
142
+ "
143
+ The URL can be a relative URL
144
+ "
145
+ # E.g : And visit relative url '/login'
146
+ visit BddHelper.base_url + url
147
+ end
148
+
149
+ When(/^maximize window$/) do
150
+ "
151
+ This maximizes the current window
152
+ "
153
+ # E.g : And maximize window
154
+ page.driver.browser.manage.window.maximize
155
+ end
156
+
157
+ When(/^accept alert$/) do
158
+ # E.g : And accept alert
159
+ page.driver.browser.switch_to.alert.accept
160
+ end
161
+
162
+ When(/^dismiss alert$/) do
163
+ # E.g : And dismiss alert
164
+ page.driver.browser.switch_to.alert.dismiss
165
+ end
166
+
167
+ When(/^get window title$/) do
168
+ "
169
+ This gets title of the current page then defines it to the global variable
170
+ "
171
+ # E.g : And get window title
172
+ $page_title = title
173
+ end
174
+
175
+ rescue StandardError => e
176
+ puts e
177
+ end
178
+
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: 0.0.4
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - kloia
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-02 00:00:00.000000000 Z
11
+ date: 2022-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -16,94 +16,101 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.11'
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: '2.11'
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: '2.4'
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: '2.4'
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.5'
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: 3.5.0
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: '3.5'
71
+ version: '4.0'
70
72
  - - ">="
71
73
  - !ruby/object:Gem::Version
72
- version: 3.5.0
74
+ version: 4.0.3
73
75
  - !ruby/object:Gem::Dependency
74
- name: selenium-webdriver
76
+ name: faker
75
77
  requirement: !ruby/object:Gem::Requirement
76
78
  requirements:
77
- - - '='
79
+ - - "~>"
78
80
  - !ruby/object:Gem::Version
79
- version: 3.4.0
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: 3.4.0
87
- description: Package of helper step definitions for BDD testing with Gherkin and Cucumber
88
- email: ping@kloia.co.uk
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/steps/assertion.rb
95
- - lib/steps/browser.rb
96
- - lib/steps/check.rb
97
- - lib/steps/click.rb
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/fill.rb
100
- - lib/steps/select.rb
101
- - lib/steps/unclassified.rb
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
102
109
  homepage: http://rubygems.org/gems/bdd-helper
103
110
  licenses:
104
111
  - MIT
105
112
  metadata: {}
106
- post_install_message:
113
+ post_install_message:
107
114
  rdoc_options: []
108
115
  require_paths:
109
116
  - lib
@@ -118,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
125
  - !ruby/object:Gem::Version
119
126
  version: '0'
120
127
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.6.12
123
- signing_key:
128
+ rubygems_version: 3.2.22
129
+ signing_key:
124
130
  specification_version: 4
125
- summary: Helper step definitions for Gherkin
131
+ summary: Helper steps for client-based automation testing
126
132
  test_files: []
@@ -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
@@ -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