-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathglobal.js
74 lines (63 loc) · 2.01 KB
/
global.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
(function() {
'use strict';
// Helper functions
global.clearWithBackspace = function(elementFinder) {
return elementFinder.getAttribute('value').then(function(value) {
var backspaces = '',
length = value.length;
for (var i = 0; i < length; i++) {
backspaces += protractor.Key.BACK_SPACE;
}
return elementFinder.sendKeys(backspaces);
});
};
/**
* Provides a place to put common beforeEach functionality.
*/
global.setUp = function() {
// Add our custom jasmine matchers
jasmine.getEnv().currentSpec.addMatchers(matchers.getCustomMatchers());
// Reset any excluded test-specific console errors.
global.consoleErrorHandler.resetExcluded();
// Close any hanging dialogs before running tests
sdk.closeDialogs();
};
/**
* Provides a place to put common afterEach functionality.
*/
global.tearDown = function() {
// Check console.log for errors
global.consoleErrorHandler.expectNoConsoleErrors();
// Check for hanging dialogs
sdk.expectNoDialogs();
};
function displayed(elementFinder, optionalTimeout, isDisplayed) {
browser.driver.wait(function () {
return elementFinder.isDisplayed().then(function (result) {
return result === isDisplayed;
});
}, optionalTimeout || 60000);
}
function present(elementFinder, optionalTimeout, isPresent) {
browser.driver.wait(function () {
return elementFinder.isPresent().then(function (result) {
return result === isPresent;
});
}, optionalTimeout || 60000);
}
global.wait = {
until: {
not: {
present: function (elementFinder, optionalTimeout) {
return present(elementFinder, optionalTimeout, false);
}
},
displayed: function (elementFinder, optionalTimeout) {
return displayed(elementFinder, optionalTimeout, true);
},
present: function (elementFinder, optionalTimeout) {
return present(elementFinder, optionalTimeout, true);
}
}
};
}());