-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistration.js
90 lines (78 loc) · 2.88 KB
/
registration.js
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
// Registration page
describe('Test suite for the way2automation registration dummy appliacation', () => {
const scope = element(by.className('ng-scope'));
const logout = element(by.linkText('Logout'));
const user = element(by.id('username'));
const user2 = element(by.model('model[options.key]'));
const pass = element(by.id('password'));
const button = element(by.className('btn btn-danger'));
//Set up fresh session for each test
beforeEach(() => {
browser.get('http://www.way2automation.com/angularjs-protractor/registeration/#/login');
});
// Helper fuctions
const login = (username, password, username2 = username) => {
user.sendKeys(username);
user2.sendKeys(username2);
pass.sendKeys(password);
button.click();
}
const genString = (len) => {
let str = '';
for(let i = 0; i < len; i++) {
str += 'a';
}
return str;
}
const clearInput = () => {
user.clear();
user2.clear();
pass.clear();
}
it('Should have a title', () => {
expect(browser.getTitle()).toEqual('Protractor practice website - Registration');
});
it('Should disable the login button with missing fields', () => {
expect(button.isEnabled()).toBe(false);
user.sendKeys(genString(3));
expect(button.isEnabled()).toBe(false);
pass.sendKeys(genString(3));
expect(button.isEnabled()).toBe(false);
user2.sendKeys(genString(3));
expect(button.isEnabled()).toBe(true);
});
it('should allow login and out with valid credentials', () => {
login('angular', 'password');
expect(scope.getText()).toContain("You're logged in!!");
logout.click();
expect(scope.isPresent()).toBe(true);
login('angular', 'password', 'null');
expect(scope.getText()).toContain("You're logged in!!");
logout.click();
expect(scope.isPresent()).toBe(true);
login('null', 'password', 'angular');
expect(scope.getText()).toContain("Username or password is incorrect");
});
it('Should take input between 3 and 30 characters', () => {
user.sendKeys(genString(2));
pass.sendKeys(genString(2));
user2.sendKeys(genString(2));
expect(button.isEnabled()).toBe(false);
clearInput();
user.sendKeys(genString(3));
pass.sendKeys(genString(3));
user2.sendKeys(genString(3));
expect(button.isEnabled()).toBe(true);
clearInput();
user.sendKeys(genString(50));
pass.sendKeys(genString(50));
user2.sendKeys(genString(50));
expect(button.isEnabled()).toBe(true);
clearInput();
user.sendKeys(genString(51));
pass.sendKeys(genString(51));
user2.sendKeys(genString(51));
expect(button.isEnabled()).toBe(false);
clearInput();
})
})