-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotractor-spec.js
More file actions
123 lines (102 loc) · 3.85 KB
/
protractor-spec.js
File metadata and controls
123 lines (102 loc) · 3.85 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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* wdBrowser: Same as browser, just bridged
*/
/**
* SAMPLES:
wdBrowser.currentContext().then(function (context) {
console.log('\n' + "Context: ", context);
});
wdBrowser
.contexts().then(function (contexts) { // get list of available views. Returns array: ["NATIVE_APP","WEBVIEW_1"]
console.log("contexts");
console.log(contexts);
//return wdBrowser.context(contexts[1]); // choose the webview context
});
*/
describe('Appium app Dashboard', function () {
beforeEach(function () {
//browser.ignoreSynchronization = false; // Should be default
});
it('should always pass this true test', function () {
expect(true).toBeTruthy();
});
it("should use WEBVIEW_1 as context", function (done) {
wdBrowser.currentContext().then(function (context) {
console.log('\n' + "Context: ", context);
expect(context).toEqual('WEBVIEW_1');
done();
});
});
it('should be able to use wdBrowser', function (done) {
wdBrowser.title().then(function (title) {
expect(title).toEqual('Dashboard');
}).nodeify(done);
});
// Error: TypeError: undefined is not a function
xit('should convert to wd element', function (done) {
//var el = element.all(by.css('.title')).get(1);
var el = element.all(by.css('body > ion-nav-bar > div:nth-child(3) > ion-header-bar > div.title'));
wdBrowser.wdEl(el).text()
.then(function (text) {
expect(text).toEqual('Dashboard');
}).nodeify(done);
});
it('should convert from wd element if we give it css selector that returns only one element', function (done) {
return wdBrowser
.elementByCss('body > ion-nav-bar > div:nth-child(3) > ion-header-bar > div.title')
.then(function (el) {
return wdBrowser.swEl(el).getText()
.then(function (text) {
expect(text).toEqual('Dashboard');
});
}).nodeify(done);
});
// NB: Note plural elementsByCss()
it('should convert from wd element if we give it css selector that returns multiple elements', function (done) {
return wdBrowser
.elementsByCss('.title')
.then(function (el) {
return wdBrowser.swEl(el[1]).getText()
.then(function (text) {
expect(text).toEqual('Dashboard');
});
}).nodeify(done);
});
xit('should be as normal Protractor test as possible', function () {
//console.log("wdBrowser:");
//console.log(wdBrowser);
//wdBrowser.currentContext().then(function (context) {
// console.log("context start:");
// console.log(context);
//});
//wdBrowser
// .contexts().then(function (contexts) { // get list of available views. Returns array: ["NATIVE_APP","WEBVIEW_1"]
// console.log("contexts");
// console.log(contexts);
// //return wdBrowser.context(contexts[1]); // choose the webview context
// });
//wdBrowser.currentContext().then(function (context) {
// console.log("context ready:");
// console.log(context);
//});
//browser.get('http://localhost:8100');
//wdBrowser.get('http://localhost:8100');
console.log("expect before");
//console.log("actual", element.all(by.css('.title')).get(1));
//element.all(by.css('.title')).get(1)
// .then(function (theText) {
// console.log("expect then", theText);
// //expect(theText).toEqual('Dashboard');
// });
//expect(element.all(by.css('.title')).get(1).getText()).toEqual('Dashboard');
//expect(element(by.css('.title')).getText()).toEqual('Dashboard');
//element.all(by.css('.title')).get(1).getText()
// .then(function (theText) {
// console.log("expect then", theText);
// expect(theText).toEqual('Dashboard');
// done();
// });
console.log("expect after");
//done();
});
});