selenium-cucumber 0.0.6 → 0.0.7
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.
- data/doc/canned_steps.md +31 -31
- data/doc/selenium-cucumber-help.txt +16 -0
- data/lib/selenium-cucumber/assertion_steps.rb +40 -409
- data/lib/selenium-cucumber/click_elements_steps.rb +3 -22
- data/lib/selenium-cucumber/input_steps.rb +31 -280
- data/lib/selenium-cucumber/methods/assertion_methods.rb +34 -77
- data/lib/selenium-cucumber/methods/misc_methods.rb +21 -0
- data/lib/selenium-cucumber/methods/navigate_methods.rb +5 -1
- data/lib/selenium-cucumber/methods/press_button_methods.rb +6 -0
- data/lib/selenium-cucumber/methods/required_files.rb +1 -1
- data/lib/selenium-cucumber/navigation_steps.rb +7 -35
- data/lib/selenium-cucumber/press_button_steps.rb +19 -0
- data/lib/selenium-cucumber/progress_steps.rb +6 -43
- data/lib/selenium-cucumber/version.rb +1 -1
- metadata +6 -2
@@ -2,321 +2,72 @@ require_relative 'methods/input_methods'
|
|
2
2
|
|
3
3
|
#enter text into input field steps
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
Then(/^I enter "([^\"]*)" into input field having (.+) "([^\"]*)"$/) do |text, type, access_name|
|
6
|
+
validate_locator type
|
7
|
+
enter_text(type,text,access_name)
|
8
8
|
end
|
9
9
|
|
10
|
-
#By NAME
|
11
|
-
Then(/^I enter "([^\"]*)" into input field having name "([^\"]*)"$/) do |text, access_name|
|
12
|
-
enter_text("name",text,access_name)
|
13
|
-
end
|
14
|
-
|
15
|
-
#By CLASS
|
16
|
-
Then(/^I enter "([^\"]*)" into input field having class "([^\"]*)"$/) do |text, access_name|
|
17
|
-
enter_text("class",text,access_name)
|
18
|
-
end
|
19
|
-
|
20
|
-
#By XPATH
|
21
|
-
Then(/^I enter "([^\"]*)" into input field having xpath "([^\"]*)"$/) do |text, access_name|
|
22
|
-
enter_text("xpath",text,access_name)
|
23
|
-
end
|
24
|
-
|
25
|
-
#By CSS
|
26
|
-
Then(/^I enter "([^\"]*)" into input field having css "([^\"]*)"$/) do |text, access_name|
|
27
|
-
enter_text("css",text,access_name)
|
28
|
-
end
|
29
10
|
|
30
11
|
#clear input field steps
|
31
12
|
|
32
|
-
|
33
|
-
|
34
|
-
clear_text(
|
35
|
-
end
|
36
|
-
|
37
|
-
#By NAME
|
38
|
-
Then(/^I clear input field having name "([^\"]*)"$/) do |access_name|
|
39
|
-
clear_text("name",access_name)
|
40
|
-
end
|
41
|
-
|
42
|
-
#By CLASS
|
43
|
-
Then(/^I clear input field having class "([^\"]*)"$/) do |access_name|
|
44
|
-
clear_text("class",access_name)
|
45
|
-
end
|
46
|
-
|
47
|
-
#By XPATH
|
48
|
-
Then(/^I clear input field having xpath "([^\"]*)"$/) do |access_name|
|
49
|
-
clear_text("xpath",access_name)
|
50
|
-
end
|
51
|
-
|
52
|
-
#By CSS
|
53
|
-
Then(/^I clear input field having css "([^\"]*)"$/) do |access_name|
|
54
|
-
clear_text("css",access_name)
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
#select option by text from Drop down list
|
59
|
-
#By TEXT
|
60
|
-
#By ID
|
61
|
-
Then(/^I select "(.*?)" option by text from dropdown having id "(.*?)"$/) do |option, access_name|
|
62
|
-
select_option_from_dropdown("id","text",option,access_name)
|
63
|
-
end
|
64
|
-
|
65
|
-
#By NAME
|
66
|
-
Then(/^I select "(.*?)" option by text from dropdown having name "(.*?)"$/) do |option, access_name|
|
67
|
-
select_option_from_dropdown("name","text",option,access_name)
|
68
|
-
end
|
69
|
-
|
70
|
-
#By CLASS
|
71
|
-
Then(/^I select "(.*?)" option by text from dropdown having class "(.*?)"$/) do |option, access_name|
|
72
|
-
select_option_from_dropdown("class","text",option,access_name)
|
73
|
-
end
|
74
|
-
|
75
|
-
#By XPATH
|
76
|
-
Then(/^I select "(.*?)" option by text from dropdown having xpath "(.*?)"$/) do |option, access_name|
|
77
|
-
select_option_from_dropdown("xpath","text",option,access_name)
|
78
|
-
end
|
79
|
-
|
80
|
-
#By CSS
|
81
|
-
Then(/^I select "(.*?)" option by text from dropdown having css "(.*?)"$/) do |option, access_name|
|
82
|
-
select_option_from_dropdown("css","text",option,access_name)
|
83
|
-
end
|
84
|
-
|
85
|
-
#select option by index from Drop down list
|
86
|
-
#By INDEX
|
87
|
-
#By ID
|
88
|
-
Then(/^I select (\d+) option by index from dropdown having id "(.*?)"$/) do |option, access_name|
|
89
|
-
select_option_from_dropdown("id","index",option,access_name)
|
90
|
-
end
|
91
|
-
|
92
|
-
#By NAME
|
93
|
-
Then(/^I select (\d+) option by index from dropdown having name "(.*?)"$/) do |option, access_name|
|
94
|
-
select_option_from_dropdown("name","index",option,access_name)
|
95
|
-
end
|
96
|
-
|
97
|
-
#By CLASS
|
98
|
-
Then(/^I select (\d+) option by index from dropdown having class "(.*?)"$/) do |option, access_name|
|
99
|
-
select_option_from_dropdown("class","index",option,access_name)
|
13
|
+
Then(/^I clear input field having (.+) "([^\"]*)"$/) do |type, access_name|
|
14
|
+
validate_locator type
|
15
|
+
clear_text(type, access_name)
|
100
16
|
end
|
101
17
|
|
102
|
-
#By XPATH
|
103
|
-
Then(/^I select (\d+) option by index from dropdown having xpath "(.*?)"$/) do |option, access_name|
|
104
|
-
select_option_from_dropdown("xpath","index",option,access_name)
|
105
|
-
end
|
106
18
|
|
107
|
-
#
|
108
|
-
Then(/^I select (\d+) option by index from dropdown having css "(.*?)"$/) do |option, access_name|
|
109
|
-
select_option_from_dropdown("css","index",option,access_name)
|
110
|
-
end
|
19
|
+
#select option by text from dropdown/multiselect
|
111
20
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
select_option_from_dropdown("id","value",option,access_name)
|
117
|
-
end
|
118
|
-
|
119
|
-
#By NAME
|
120
|
-
Then(/^I select "(.*?)" option by value from dropdown having name "(.*?)"$/) do |option, access_name|
|
121
|
-
select_option_from_dropdown("name","value",option,access_name)
|
122
|
-
end
|
123
|
-
|
124
|
-
#By CLASS
|
125
|
-
Then(/^I select "(.*?)" option by value from dropdown having class "(.*?)"$/) do |option, access_name|
|
126
|
-
select_option_from_dropdown("class","value",option,access_name)
|
127
|
-
end
|
128
|
-
|
129
|
-
#By XPATH
|
130
|
-
Then(/^I select "(.*?)" option by value from dropdown having xpath "(.*?)"$/) do |option, access_name|
|
131
|
-
select_option_from_dropdown("xpath","value",option,access_name)
|
132
|
-
end
|
133
|
-
|
134
|
-
#By CSS
|
135
|
-
Then(/^I select "(.*?)" option by value from dropdown having css "(.*?)"$/) do |option, access_name|
|
136
|
-
select_option_from_dropdown("css","value",option,access_name)
|
21
|
+
Then(/^I select "(.*?)" option by (.+) from dropdown having (.+) "(.*?)"$/) do |option,option_by, type, access_name|
|
22
|
+
validate_locator type
|
23
|
+
validate_option_by option_by
|
24
|
+
select_option_from_dropdown(type, option_by,option,access_name)
|
137
25
|
end
|
138
26
|
|
139
27
|
|
140
28
|
#unselect option from dropdown list
|
141
29
|
|
142
|
-
|
143
|
-
|
144
|
-
|
30
|
+
Then(/^I unselect options from dropdown having (.+) "(.*?)"$/) do |type,access_name|
|
31
|
+
validate_locator type
|
32
|
+
unselect_option_from_dropdown(type, access_name)
|
145
33
|
end
|
146
34
|
|
147
|
-
#By NAME
|
148
|
-
Then(/^I unselect options from dropdown having name "(.*?)"$/) do |access_name|
|
149
|
-
unselect_option_from_dropdown("name", access_name)
|
150
|
-
end
|
151
|
-
|
152
|
-
#By CLASS
|
153
|
-
Then(/^I unselect options from dropdown having class "(.*?)"$/) do |access_name|
|
154
|
-
unselect_option_from_dropdown("class", access_name)
|
155
|
-
end
|
156
|
-
|
157
|
-
#By XPATH
|
158
|
-
Then(/^I unselect options from dropdown having xpath "(.*?)"$/) do |access_name|
|
159
|
-
unselect_option_from_dropdown("xpath", access_name)
|
160
|
-
end
|
161
|
-
|
162
|
-
#By CSS
|
163
|
-
Then(/^I unselect options from dropdown having css "(.*?)"$/) do |access_name|
|
164
|
-
unselect_option_from_dropdown("css", access_name)
|
165
|
-
end
|
166
35
|
|
167
36
|
#check checkbox steps
|
168
|
-
#By ID
|
169
|
-
Then(/^I check checkbox having id "(.*?)"$/) do |access_name|
|
170
|
-
check_checkbox("id",access_name)
|
171
|
-
end
|
172
|
-
|
173
|
-
#By NAME
|
174
|
-
Then(/^I check checkbox having name "(.*?)"$/) do |access_name|
|
175
|
-
check_checkbox("name",access_name)
|
176
|
-
end
|
177
37
|
|
178
|
-
|
179
|
-
|
180
|
-
check_checkbox(
|
181
|
-
end
|
182
|
-
|
183
|
-
#By XPATH
|
184
|
-
Then(/^I check checkbox having xpath "(.*?)"$/) do |access_name|
|
185
|
-
check_checkbox("xpath",access_name)
|
186
|
-
end
|
187
|
-
|
188
|
-
#By CSS
|
189
|
-
Then(/^I check checkbox having css "(.*?)"$/) do |access_name|
|
190
|
-
check_checkbox("css",access_name)
|
38
|
+
Then(/^I check checkbox having (.+) "(.*?)"$/) do |type, access_name|
|
39
|
+
validate_locator type
|
40
|
+
check_checkbox(type, access_name)
|
191
41
|
end
|
192
42
|
|
193
43
|
#uncheck checkbox steps
|
194
|
-
#By ID
|
195
|
-
Then(/^I uncheck checkbox having id "(.*?)"$/) do |access_name|
|
196
|
-
uncheck_checkbox("id",access_name)
|
197
|
-
end
|
198
44
|
|
199
|
-
|
200
|
-
|
201
|
-
uncheck_checkbox(
|
45
|
+
Then(/^I uncheck checkbox having (.+) "(.*?)"$/) do |type, access_name|
|
46
|
+
validate_locator type
|
47
|
+
uncheck_checkbox(type,access_name)
|
202
48
|
end
|
203
49
|
|
204
|
-
#By CLASS
|
205
|
-
Then(/^I uncheck checkbox having class "(.*?)"$/) do |access_name|
|
206
|
-
uncheck_checkbox("class",access_name)
|
207
|
-
end
|
208
|
-
|
209
|
-
#By XPATH
|
210
|
-
Then(/^I uncheck checkbox having xpath "(.*?)"$/) do |access_name|
|
211
|
-
uncheck_checkbox("xpath",access_name)
|
212
|
-
end
|
213
|
-
|
214
|
-
#By CSS
|
215
|
-
Then(/^I uncheck checkbox having css "(.*?)"$/) do |access_name|
|
216
|
-
uncheck_checkbox("css",access_name)
|
217
|
-
end
|
218
50
|
|
219
51
|
#Steps to toggle checkbox
|
220
|
-
#By ID
|
221
|
-
Then(/^toggle checkbox having id "(.*?)"$/) do |access_name|
|
222
|
-
toggle_checkbox("id",access_name)
|
223
|
-
end
|
224
52
|
|
225
|
-
|
226
|
-
|
227
|
-
toggle_checkbox(
|
53
|
+
Then(/^toggle checkbox having (.+) "(.*?)"$/) do |type, access_name|
|
54
|
+
validate_locator type
|
55
|
+
toggle_checkbox(type,access_name)
|
228
56
|
end
|
229
57
|
|
230
|
-
#By CLASS
|
231
|
-
Then(/^toggle checkbox having class "(.*?)"$/) do |access_name|
|
232
|
-
toggle_checkbox("class",access_name)
|
233
|
-
end
|
234
58
|
|
235
|
-
#
|
236
|
-
Then(/^toggle checkbox having xpath "(.*?)"$/) do |access_name|
|
237
|
-
toggle_checkbox("xpath",access_name)
|
238
|
-
end
|
59
|
+
#radio button select step
|
239
60
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
end
|
244
|
-
|
245
|
-
#radio button select steps
|
246
|
-
#By ID
|
247
|
-
Then(/^I select radio button having id "(.*?)"$/) do |access_name|
|
248
|
-
select_radio_button("id",access_name)
|
249
|
-
end
|
250
|
-
|
251
|
-
#By NAME
|
252
|
-
Then(/^I select radio button having name "(.*?)"$/) do |access_name|
|
253
|
-
select_radio_button("name",access_name)
|
254
|
-
end
|
255
|
-
|
256
|
-
#By CLASS
|
257
|
-
Then(/^I select radio button having class "(.*?)"$/) do |access_name|
|
258
|
-
select_radio_button("class",access_name)
|
259
|
-
end
|
260
|
-
|
261
|
-
#By XPATH
|
262
|
-
Then(/^I select radio button having xpath "(.*?)"$/) do |access_name|
|
263
|
-
select_radio_button("xpath",access_name)
|
264
|
-
end
|
265
|
-
|
266
|
-
#By CSS
|
267
|
-
Then(/^I select radio button having css "(.*?)"$/) do |access_name|
|
268
|
-
select_radio_button("css",access_name)
|
61
|
+
Then(/^I select radio button having (.+) "(.*?)"$/) do |type,access_name|
|
62
|
+
validate_locator type
|
63
|
+
select_radio_button(type,access_name)
|
269
64
|
end
|
270
65
|
|
271
66
|
|
272
67
|
#steps to select option by text from radio button group
|
273
|
-
#By ID
|
274
|
-
Then(/^I select "(.*?)" option by text from radio button group having id "(.*?)"$/) do |option, access_name|
|
275
|
-
select_option_from_radio_button_group("id","text",option,access_name)
|
276
|
-
end
|
277
|
-
|
278
|
-
#By NAME
|
279
|
-
Then(/^I select "(.*?)" option by text from radio button group having name "(.*?)"$/) do |option, access_name|
|
280
|
-
select_option_from_radio_button_group("name","text",option,access_name)
|
281
|
-
end
|
282
|
-
|
283
|
-
#By CLASS
|
284
|
-
Then(/^I select "(.*?)" option by text from radio button group having class "(.*?)"$/) do |option, access_name|
|
285
|
-
select_option_from_radio_button_group("class","text",option,access_name)
|
286
|
-
end
|
287
68
|
|
288
|
-
|
289
|
-
|
290
|
-
|
69
|
+
Then(/^I select "(.*?)" option by (.+) from radio button group having (.+) "(.*?)"$/) do |option,option_by, type, access_name|
|
70
|
+
validate_locator type
|
71
|
+
validate_option_by option_by
|
72
|
+
select_option_from_radio_button_group(type,option_by,option,access_name)
|
291
73
|
end
|
292
|
-
|
293
|
-
#By CSS
|
294
|
-
Then(/^I select "(.*?)" option by text from radio button group having css "(.*?)"$/) do |option, access_name|
|
295
|
-
select_option_from_radio_button_group("css","text",option,access_name)
|
296
|
-
end
|
297
|
-
|
298
|
-
#steps to select option by value from radio button group
|
299
|
-
#By ID
|
300
|
-
Then(/^I select "(.*?)" option by value from radio button group having id "(.*?)"$/) do |option, access_name|
|
301
|
-
select_option_from_radio_button_group("id","value",option,access_name)
|
302
|
-
end
|
303
|
-
|
304
|
-
#By NAME
|
305
|
-
Then(/^I select "(.*?)" option by value from radio button group having name "(.*?)"$/) do |option, access_name|
|
306
|
-
select_option_from_radio_button_group("name","value",option,access_name)
|
307
|
-
end
|
308
|
-
|
309
|
-
#By CLASS
|
310
|
-
Then(/^I select "(.*?)" option by value from radio button group having class "(.*?)"$/) do |option, access_name|
|
311
|
-
select_option_from_radio_button_group("class","value",option,access_name)
|
312
|
-
end
|
313
|
-
|
314
|
-
#By XPATH
|
315
|
-
Then(/^I select "(.*?)" option by value from radio button group having xpath "(.*?)"$/) do |option, access_name|
|
316
|
-
select_option_from_radio_button_group("xpath","value",option,access_name)
|
317
|
-
end
|
318
|
-
|
319
|
-
#By CSS
|
320
|
-
Then(/^I select "(.*?)" option by value from radio button group having css "(.*?)"$/) do |option, access_name|
|
321
|
-
select_option_from_radio_button_group("css","value",option,access_name)
|
322
|
-
end
|
@@ -54,14 +54,14 @@ def check_element_enable(access_type, access_name, test_case)
|
|
54
54
|
end
|
55
55
|
|
56
56
|
#method to get attribute value
|
57
|
-
def get_element_attribute(access_type,access_name,
|
57
|
+
def get_element_attribute(access_type,access_name,attribute_name)
|
58
58
|
return WAIT.until{$driver.find_element(:"#{access_type}" => "#{access_name}")}.attribute("#{attribute_name}")
|
59
59
|
end
|
60
60
|
|
61
61
|
#method to check attribute value
|
62
|
-
def check_element_attribute(access_type, attribute_name
|
62
|
+
def check_element_attribute(access_type, attribute_name, attribute_value, access_name, test_case)
|
63
63
|
|
64
|
-
attr_val=get_element_attribute(access_type,access_name,
|
64
|
+
attr_val=get_element_attribute(access_type, access_name, attribute_name)
|
65
65
|
|
66
66
|
if test_case
|
67
67
|
if(attr_val!=attribute_value)
|
@@ -81,25 +81,31 @@ end
|
|
81
81
|
|
82
82
|
# method to check element presence
|
83
83
|
def check_element_presence(access_type, access_name, test_case)
|
84
|
-
result = is_element_displayed(access_type,access_name)
|
85
|
-
|
86
84
|
if test_case
|
87
|
-
if !
|
85
|
+
if !is_element_displayed(access_type,access_name)
|
88
86
|
raise "Exception : Element Not Present"
|
89
87
|
end
|
90
88
|
else
|
91
|
-
|
92
|
-
|
89
|
+
begin
|
90
|
+
if is_element_displayed(access_type,access_name)
|
91
|
+
raise "Present"
|
92
|
+
end
|
93
|
+
rescue Exception => e
|
94
|
+
if e.message=="present"
|
95
|
+
raise "Exception : Element Present"
|
96
|
+
end
|
93
97
|
end
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
97
101
|
#method to assert checkbox check
|
98
|
-
def is_checkbox_checked(access_type, access_name)
|
102
|
+
def is_checkbox_checked(access_type, access_name, should_be_checked=true)
|
99
103
|
checkbox = WAIT.until{$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
100
104
|
|
101
|
-
if !checkbox.selected?
|
105
|
+
if !checkbox.selected? && should_be_checked
|
102
106
|
raise "Checkbox not checked"
|
107
|
+
elsif checkbox.selected? && !should_be_checked
|
108
|
+
raise "Checkbox is checked"
|
103
109
|
end
|
104
110
|
end
|
105
111
|
|
@@ -113,78 +119,29 @@ def is_checkbox_unchecked(access_type, access_name)
|
|
113
119
|
end
|
114
120
|
|
115
121
|
#method to assert checkbox check
|
116
|
-
def is_radio_button_selected(access_type, access_name)
|
117
|
-
radio_button = WAIT.until{$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
118
|
-
|
119
|
-
if !radio_button.selected?
|
120
|
-
raise "Radio button is not selected"
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
#method to assert checkbox uncheck
|
125
|
-
def is_radio_button_unselected(access_type, access_name)
|
122
|
+
def is_radio_button_selected(access_type, access_name, should_be_selected=true)
|
126
123
|
radio_button = WAIT.until{$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
127
|
-
|
128
|
-
|
129
|
-
raise "Radio
|
124
|
+
|
125
|
+
if !radio_button.selected? && should_be_selected
|
126
|
+
raise "Radio Button not selected"
|
127
|
+
elsif radio_button.selected? && !should_be_selected
|
128
|
+
raise "Radio Button is selected"
|
130
129
|
end
|
131
130
|
end
|
132
131
|
|
133
132
|
|
134
133
|
#method to assert option from radio button group is selected
|
135
|
-
def is_option_from_radio_button_group_selected(access_type, by, option, access_name)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
end
|
148
|
-
i=i+1
|
149
|
-
end
|
150
|
-
else
|
151
|
-
while i<radio_button_group.length
|
152
|
-
if radio_button_group[i].text==option
|
153
|
-
if !radio_button_group[i].selected?
|
154
|
-
raise "Radio button is not selected"
|
155
|
-
end
|
156
|
-
break
|
157
|
-
end
|
158
|
-
i=i+1
|
159
|
-
end
|
160
|
-
end
|
134
|
+
def is_option_from_radio_button_group_selected(access_type, by, option, access_name, should_be_selected=true)
|
135
|
+
radio_button_group = WAIT.until{$driver.find_elements(:"#{access_type}" => "#{access_name}")}
|
136
|
+
|
137
|
+
getter = ->(rb, by) { by == 'value' ? rb.attribute('value') : rb.text }
|
138
|
+
|
139
|
+
ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
|
140
|
+
|
141
|
+
if !ele.selected && should_be_selected
|
142
|
+
raise 'Radio button is not selected'
|
143
|
+
elsif ele.selected && !should_be_selected
|
144
|
+
raise 'Radio button is selected'
|
145
|
+
end
|
161
146
|
end
|
162
147
|
|
163
|
-
#method to assert option from radio button group is not selected
|
164
|
-
def is_option_from_radio_button_group_not_selected(access_type, by, option, access_name)
|
165
|
-
radio_button_group = WAIT.until{$driver.find_elements(:"#{access_type}" => "#{access_name}")}
|
166
|
-
|
167
|
-
i=0
|
168
|
-
|
169
|
-
if by=="value"
|
170
|
-
while i<radio_button_group.length
|
171
|
-
if radio_button_group[i].attribute("value")==option
|
172
|
-
if radio_button_group[i].selected?
|
173
|
-
raise "Radio button is selected"
|
174
|
-
end
|
175
|
-
break
|
176
|
-
end
|
177
|
-
i=i+1
|
178
|
-
end
|
179
|
-
else
|
180
|
-
while i<radio_button_group.length
|
181
|
-
if radio_button_group[i].text==option
|
182
|
-
if radio_button_group[i].selected?
|
183
|
-
raise "Radio button is selected"
|
184
|
-
end
|
185
|
-
break
|
186
|
-
end
|
187
|
-
i=i+1
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
# WAIT instance for explicit wait
|
3
|
+
WAIT = Selenium::WebDriver::Wait.new(:timeout => 30)
|
4
|
+
|
5
|
+
#method to validate locator
|
6
|
+
def valid_locator_type? type
|
7
|
+
%w(id class css name xpath).include? type
|
8
|
+
end
|
9
|
+
|
10
|
+
def validate_locator type
|
11
|
+
raise "Invalid locator type - #{type}" unless valid_locator_type? type
|
12
|
+
end
|
13
|
+
|
14
|
+
#method to validate dropdown selector
|
15
|
+
def valid_option_by? option_by
|
16
|
+
%w(text value index).include? option_by
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate_option_by option_by
|
20
|
+
raise "Invalid option by - #{option_by}" unless valid_locator_type? option_by
|
21
|
+
end
|
@@ -26,27 +26,13 @@ Then(/^I refresh page$/) do
|
|
26
26
|
$driver.navigate.refresh
|
27
27
|
end
|
28
28
|
|
29
|
-
#steps to scroll to element
|
30
|
-
Then(/^I scroll to the element having id "(.*?)"$/) do |access_name|
|
31
|
-
scroll_to_element("id",access_name)
|
32
|
-
end
|
33
|
-
|
34
|
-
Then(/^I scroll to the element having name "(.*?)"$/) do |access_name|
|
35
|
-
scroll_to_element("name",access_name)
|
36
|
-
end
|
37
29
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
Then(/^I scroll to the element having xpath "(.*?)"$/) do |access_name|
|
43
|
-
scroll_to_element("xpath",access_name)
|
30
|
+
#steps to scroll to element
|
31
|
+
Then(/^I scroll to the element having (.+) "(.*?)"$/) do |type, access_name|
|
32
|
+
validate_locator type
|
33
|
+
scroll_to_element(type,access_name)
|
44
34
|
end
|
45
35
|
|
46
|
-
Then(/^I scroll to the element having css "(.*?)"$/) do |access_name|
|
47
|
-
scroll_to_element("css",access_name)
|
48
|
-
end
|
49
|
-
|
50
36
|
#steps to zoom in page
|
51
37
|
Then(/^I zoom in page$/) do
|
52
38
|
zoom_in_out("add")
|
@@ -59,25 +45,11 @@ end
|
|
59
45
|
|
60
46
|
|
61
47
|
#steps to zoom out till element displays
|
62
|
-
Then(/^I zoom out page till I see element having
|
63
|
-
|
48
|
+
Then(/^I zoom out page till I see element having (.+) "(.*?)"$/) do |type,access_name|
|
49
|
+
validate_locator type
|
50
|
+
zoom_in_out_till_element_display(type, "subtract", access_name)
|
64
51
|
end
|
65
52
|
|
66
|
-
Then(/^I zoom out page till I see element having name "(.*?)"$/) do |access_name|
|
67
|
-
zoom_in_out_till_element_display("name", "subtract", access_name)
|
68
|
-
end
|
69
|
-
|
70
|
-
Then(/^I zoom out page till I see element having class "(.*?)"$/) do |access_name|
|
71
|
-
zoom_in_out_till_element_display("class", "subtract", access_name)
|
72
|
-
end
|
73
|
-
|
74
|
-
Then(/^I zoom out page till I see element having xpath "(.*?)"$/) do |access_name|
|
75
|
-
zoom_in_out_till_element_display("xpath", "subtract", access_name)
|
76
|
-
end
|
77
|
-
|
78
|
-
Then(/^I zoom out page till I see element having css "(.*?)"$/) do |access_name|
|
79
|
-
zoom_in_out_till_element_display("css", "subtract", access_name)
|
80
|
-
end
|
81
53
|
|
82
54
|
Then(/^I reset page view$/) do
|
83
55
|
zoom_in_out("numpad0")
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'methods/press_button_methods'
|
2
|
+
|
3
|
+
# click on web element
|
4
|
+
|
5
|
+
When(/^I click on element having (.+) "(.*?)"$/) do |type, access_name|
|
6
|
+
validate_locator type
|
7
|
+
click(type,access_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
#steps to click on link
|
12
|
+
|
13
|
+
Then(/^I click on link having text "(.*?)"$/) do |access_name|
|
14
|
+
click("link",access_name)
|
15
|
+
end
|
16
|
+
|
17
|
+
Then(/^I click on link having partial text "(.*?)"$/) do |access_name|
|
18
|
+
click("partial_link_text",access_name)
|
19
|
+
end
|