This repository was archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathdriverProviderTest.js
145 lines (133 loc) · 3.92 KB
/
driverProviderTest.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/**
* Sanity integration tests for Driver Providers.
*
* Assumed setup:
* - selenium server running locally at http://localhost:4444
* - selenium jar and chromedriver in protractor/selenium, where
* webdriver-manager stores them.
* - if you want to test saucelabs, test with --sauceUser and --sauceKey
* - if you want to test browserstack driverProvider, test with
--browserstackUser and --browserstackKey
* You should verify that there are no lingering processes when these tests
* complete.
*/
const argv = require('yargs').argv;
const env = require('./environment');
const Direct = require('../built/driverProviders/direct').Direct;
const Hosted = require('../built/driverProviders/hosted').Hosted;
const Local = require('../built/driverProviders/local').Local;
const Sauce = require('../built/driverProviders/sauce').Sauce;
const BrowserStack = require('../built/driverProviders/browserStack').BrowserStack;
const testDriverProvider = async (driverProvider) => {
await driverProvider.setupEnv();
const driver = driverProvider.getNewDriver();
await driver.get('about:blank');
const url = await driver.getCurrentUrl();
if (url != 'about:blank') {
throw new Error(`url was not about:blank, instead found ${url}`);
}
if (driverProvider.updateJob) {
await driverProvider.updateJob({'passed': true});
await driverProvider.teardownEnv();
} else {
await driverProvider.teardownEnv();
}
};
const chromeConfig = {
capabilities: {
browserName: 'chrome'
}
};
testDriverProvider(new Direct(chromeConfig)).
then(() => {
console.log('direct.dp with chrome working!');
}, (err) => {
console.error('direct.dp with chrome failed with', err);
throw err;
});
const firefoxConfig = {
capabilities: {
browserName: 'firefox'
}
};
testDriverProvider(new Direct(firefoxConfig)).
then(() => {
console.log('direct.dp with firefox working!');
}, (err) => {
console.error('direct.dp with firefox failed with', err);
throw err;
});
const hostedConfig = {
seleniumAddress: env.seleniumAddress,
capabilities: {
browserName: 'firefox'
}
};
testDriverProvider(new Hosted(hostedConfig)).
then(() => {
console.log('hosted.dp working!');
}, (err) => {
console.error('hosted.dp failed with', err);
throw err;
});
const hostedPromisedConfig = {
seleniumAddress: Promise.resolve(env.seleniumAddress),
capabilities: {
browserName: 'firefox'
}
};
testDriverProvider(new Hosted(hostedPromisedConfig)).
then(() => {
console.log('hosted.dp with promises working!');
}, (err) => {
console.error('hosted.dp with promises failed with', err);
throw err;
});
const localConfig = {
seleniumArgs: [],
capabilities: {
browserName: 'chrome'
}
};
testDriverProvider(new Local(localConfig)).
then(() => {
console.log('local.dp working!');
}, (err) => {
console.error('local.dp failed with', err);
throw err;
});
if (argv.sauceUser && argv.sauceKey) {
const sauceConfig = {
sauceUser: argv.sauceUser,
sauceKey: argv.sauceKey,
sauceBuild: argv.sauceBuild,
capabilities: {
browserName: 'chrome'
}
};
testDriverProvider(new Sauce(sauceConfig)).
then(() => {
console.log('sauce.dp working!');
}, (err) => {
console.error('sauce.dp failed with', err);
throw err;
});
}
if (argv.browserstackUser && argv.browserstackKey) {
const browserStackConfig = {
browserstackUser: argv.browserstackUser,
browserstackKey: argv.browserstackKey,
capabilities: {
'build': 'protractor-browserstack-spec',
'name': 'protractor-browserstack-spec',
'browserName': 'chrome',
}
};
testDriverProvider(new BrowserStack(browserStackConfig)).
then(() => {
console.log('browserstack.dp working!');
}, (err) => {
console.error('browserstack.dp failed with', err);
throw err;
});
}