-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcafetownsend.spec.js
65 lines (57 loc) · 2.08 KB
/
cafetownsend.spec.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
/**
* Created by User on 12/03/2017.
*/
describe('cafetownsend App', function() {
var name = element(by.model('user.name'));
var pwd = element(by.model('user.password'));
var loginButton = element(by.cssContainingText('.main-button', 'Login'))
var loginRes = element(by.id('greetings'));
function login(a,b){
name.sendKeys(a);
pwd.sendKeys(b);
loginButton.click();
}
beforeEach(function () {
browser.get('http://cafetownsend-angular-rails.herokuapp.com/login');
})
it('should have a title', function() {
expect(browser.getTitle()).toEqual('CafeTownsend-AngularJS-Rails');
});
it('Login test',function () {
login('Luke','Skywalker');
expect(loginRes.getText()).toEqual('Hello Luke');
//expect(loginRes.getText().toEqual('Hello Luke'))
});
it('select each employee test',function () {
login('Luke','Skywalker');
expect(loginRes.getText()).toEqual('Hello Luke');
$$('#employee-list li').each(function(element, index) {
//console.log(element.getText());
// Will print 0 First, 1 Second, 2 Third.
element.getText().then(function (text) {
console.log(index, text);
});
});
});
it('select and click employee test',function () {
login('Luke','Skywalker');
expect(loginRes.getText()).toEqual('Hello Luke');
$$('#employee-list li').filter(function(elem, index) {
return elem.getText().then(function(text) {
return text === 'edit123 last1';
});
}).first().click();
browser.sleep(5000);
});
it('select and edit employee test',function () {
login('Luke','Skywalker');
expect(loginRes.getText()).toEqual('Hello Luke');
$$('#employee-list li').filter(function(elem, index) {
return elem.getText().then(function(text) {
return text === 'edit123 last1';
});
}).first().click();
$$('#bEdit').click();
browser.sleep(5000);
});
});