-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage_object_example.js
More file actions
55 lines (40 loc) · 1.12 KB
/
page_object_example.js
File metadata and controls
55 lines (40 loc) · 1.12 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
// Example of simple page object implementation for Cypress
class SignInPage {
getEmailError = () => cy.get(`[data-cy=signInEmailError]`);
getPasswordError = () => cy.get(`[data-cy=signInPasswordError]`);
visit = () => cy.visit('/signin');
fillEmail = (value) => {
const field = cy.get(`[data-cy=signInEmailField]`);
field.clear();
field.type(value);
return this;
}
fillPassword = (value) => {
const field = cy.get(`[data-cy=signInPasswordField]`);
field.clear();
field.type(value);
return this;
}
submit = () => {
const button = cy.get(`[data-cy=signInSubmitButton]`);
button.click();
}
}
export default SignInPage;
//--------------------------------------------------------------
// Usage
describe('Sign In', () => {
it('should show an error message on empty input', () => {
const signIn = new SignInPage();
signIn.visit();
signIn.submit();
signIn.getEmailError()
.should('exist')
.contains('Email is required');
signIn
.getPasswordError()
.should('exist')
.contains('Password is required');
});
// more tests
});