Skip to content

Commit 71a7c1e

Browse files
committed
Updated datadriven
1 parent 2c84347 commit 71a7c1e

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
let cases = [
2-
{ 'username': 'locked_user', 'password': 'testingisfun99', 'error': 'Your account has been locked.' },
3-
{ 'username': 'fav_user', 'password': 'wrongpass', 'error': 'Invalid Password' },
4-
{ 'username': 'helloworld', 'password': 'testingisfun99', 'error': 'Invalid Username' }
5-
]
6-
1+
var fs = require('fs');
72
describe('StackDemo login', () => {
83

94
beforeEach('Open StackDemo', () => {
@@ -13,14 +8,22 @@ describe('StackDemo login', () => {
138
afterEach('clear sessionstorage', () => {
149
browser.execute(() => sessionStorage.clear())
1510
})
16-
cases.forEach(({username, password, error }) => {
17-
it(`should return '${ error }' for account with username '${ username }'`, function() {
18-
$('#signin').click();
19-
$('#username input').setValue(username + '\n');
20-
$('#password input').setValue(password + '\n');
21-
$('#login-btn').click();
2211

23-
expect($('.api-error')).toHaveText(error);
24-
})
12+
it('login should be successful', function() {
13+
describe('login should be successful for all data set', function() {
14+
testData.forEach(function(val, index) {
15+
it(`login sholud be successful for account with username '${ val.split(',')[0] }'`, function() {
16+
console.log("login sholud be successful for account with username " + val.split(',')[0])
17+
$('#signin').click();
18+
$('#username input').setValue(val.split(',')[0] + '\n');
19+
$('#password input').setValue(val.split(',')[1] + '\n');
20+
$('#login-btn').click();
21+
22+
expect($('.username')).toHaveText(val.split(',')[0]);
23+
24+
$('#logout').click();
25+
});
26+
});
27+
});
2528
});
2629
})

0 commit comments

Comments
 (0)