-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser-login.yaml
More file actions
389 lines (315 loc) · 9.52 KB
/
Copy pathbrowser-login.yaml
File metadata and controls
389 lines (315 loc) · 9.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# Complete example: Browser test for a login flow.
#
# This suite tests the authentication flow of a web application,
# including successful login, failed login, password visibility toggle,
# remember me functionality, and logout.
#
# Prerequisites:
# scrutineer browsers install
#
# Run with:
# scrutineer run --config scrutineer.yaml --tags browser
suite: "Web Application Login Flow"
tags: [browser, auth, e2e]
fixtures:
app:
url: "https://app.example.com"
valid_user:
email: "testuser@example.com"
password: "SecurePassword123!"
display_name: "Test User"
invalid_user:
email: "nobody@example.com"
password: "WrongPassword"
tests:
# ---- Successful Login ----
- name: "Login page loads correctly"
connector: browser
tags: [smoke]
steps:
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
timeout: 10s
- action: evaluate
expression: "document.title"
assert:
- field: value
operator: contains
expected: "Login"
- action: get_text
selector: "h1"
assert:
- field: text
operator: equal
expected: "Sign In"
- action: screenshot
path: "screenshots/login-page.png"
- name: "Successful login redirects to dashboard"
connector: browser
tags: [smoke]
steps:
# Navigate to login
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
timeout: 10s
# Enter credentials
- action: fill
selector: "#email"
value: ${fixture.valid_user.email}
- action: fill
selector: "#password"
value: ${fixture.valid_user.password}
# Submit
- action: click
selector: "button[type='submit']"
# Wait for dashboard to load
- action: wait_for_selector
selector: "[data-testid='dashboard']"
timeout: 15s
# Verify URL changed to dashboard
- action: evaluate
expression: "window.location.pathname"
assert:
- field: value
operator: equal
expected: "/dashboard"
# Verify welcome message shows user name
- action: get_text
selector: "[data-testid='welcome-message']"
assert:
- field: text
operator: contains
expected: ${fixture.valid_user.display_name}
# Verify navigation menu is visible
- action: wait_for_selector
selector: "nav.main-nav"
- action: screenshot
path: "screenshots/dashboard-after-login.png"
# ---- Failed Login ----
- name: "Invalid credentials show error message"
connector: browser
tags: [smoke, errors]
steps:
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
- action: fill
selector: "#email"
value: ${fixture.invalid_user.email}
- action: fill
selector: "#password"
value: ${fixture.invalid_user.password}
- action: click
selector: "button[type='submit']"
# Wait for error message
- action: wait_for_selector
selector: ".error-alert"
timeout: 10s
- action: get_text
selector: ".error-alert"
assert:
- field: text
operator: contains
expected: "Invalid email or password"
# Verify we are still on login page
- action: evaluate
expression: "window.location.pathname"
assert:
- field: value
operator: equal
expected: "/login"
# Verify password field is cleared
- action: evaluate
expression: "document.querySelector('#password').value"
assert:
- field: value
operator: equal
expected: ""
- action: screenshot
path: "screenshots/login-error.png"
- name: "Empty form submission shows validation errors"
connector: browser
tags: [validation]
steps:
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
# Click submit without filling in any fields
- action: click
selector: "button[type='submit']"
# Check for validation messages
- action: wait_for_selector
selector: ".field-error"
timeout: 5s
- action: get_text
selector: "#email-error"
assert:
- field: text
operator: contains
expected: "required"
# ---- Password Visibility ----
- name: "Password visibility toggle works"
connector: browser
steps:
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
- action: fill
selector: "#password"
value: "MySecret123"
# Verify password is hidden by default
- action: get_attribute
selector: "#password"
attribute: "type"
assert:
- field: value
operator: equal
expected: "password"
# Click the show/hide toggle
- action: click
selector: "[data-testid='toggle-password']"
# Verify password is now visible
- action: get_attribute
selector: "#password"
attribute: "type"
assert:
- field: value
operator: equal
expected: "text"
# Toggle back
- action: click
selector: "[data-testid='toggle-password']"
- action: get_attribute
selector: "#password"
attribute: "type"
assert:
- field: value
operator: equal
expected: "password"
# ---- Forgot Password ----
- name: "Forgot password link navigates correctly"
connector: browser
steps:
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
- action: click
selector: "a[href='/forgot-password']"
selector_type: css
- action: wait_for_selector
selector: "#forgot-password-form"
timeout: 10s
- action: evaluate
expression: "window.location.pathname"
assert:
- field: value
operator: equal
expected: "/forgot-password"
- action: get_text
selector: "h1"
assert:
- field: text
operator: contains
expected: "Reset Password"
# ---- Logout ----
- name: "Logout clears session and redirects to login"
connector: browser
steps:
# Login first
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
- action: fill
selector: "#email"
value: ${fixture.valid_user.email}
- action: fill
selector: "#password"
value: ${fixture.valid_user.password}
- action: click
selector: "button[type='submit']"
- action: wait_for_selector
selector: "[data-testid='dashboard']"
timeout: 15s
# Click user menu to reveal logout button
- action: click
selector: "[data-testid='user-menu']"
- action: wait_for_selector
selector: "[data-testid='logout-button']"
- action: click
selector: "[data-testid='logout-button']"
# Verify redirect to login page
- action: wait_for_selector
selector: "#login-form"
timeout: 10s
- action: evaluate
expression: "window.location.pathname"
assert:
- field: value
operator: equal
expected: "/login"
# Verify session is cleared by checking localStorage
- action: evaluate
expression: "localStorage.getItem('auth_token')"
assert:
- field: value
operator: equal
expected: null
- action: screenshot
path: "screenshots/after-logout.png"
# ---- Protected Route ----
- name: "Accessing protected page without login redirects to login"
connector: browser
steps:
- action: navigate
url: "${fixture.app.url}/dashboard"
# Should be redirected to login
- action: wait_for_selector
selector: "#login-form"
timeout: 10s
- action: evaluate
expression: "window.location.pathname"
assert:
- field: value
operator: equal
expected: "/login"
# ---- Accessibility ----
- name: "Login form has proper ARIA attributes"
connector: browser
tags: [a11y]
steps:
- action: navigate
url: "${fixture.app.url}/login"
- action: wait_for_selector
selector: "#login-form"
# Check that the email input has an accessible label
- action: get_attribute
selector: "#email"
attribute: "aria-label"
assert:
- field: value
operator: not_empty
# Check that the submit button has a role
- action: evaluate
expression: |
(function() {
var btn = document.querySelector('button[type="submit"]');
return btn && (btn.getAttribute('role') === 'button' || btn.tagName === 'BUTTON');
})()
assert:
- field: value
operator: equal
expected: true
# Check that the form has a role using role selector
- action: get_attribute
selector: "form"
selector_type: role
attribute: "aria-label"