1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const fs = require("fs");
|
4 | const path = require("path");
|
5 | const yargs = require("yargs");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | let args = [];
|
13 | process.argv.slice(2).forEach(function (arg) {
|
14 | let flag = arg.split('=')[0];
|
15 | switch (flag) {
|
16 | case 'debug':
|
17 | args.push('--nodeDebug');
|
18 | args.push('true');
|
19 | break;
|
20 | case '-d':
|
21 | case '--debug':
|
22 | case '--debug-brk':
|
23 | args.push('--v8Debug');
|
24 | args.push('true');
|
25 | break;
|
26 | default:
|
27 | args.push(arg);
|
28 | break;
|
29 | }
|
30 | });
|
31 |
|
32 | let allowedNames = [
|
33 | 'seleniumServerJar',
|
34 | 'seleniumServerStartTimeout',
|
35 | 'localSeleniumStandaloneOpts',
|
36 | 'chromeDriver',
|
37 | 'seleniumAddress',
|
38 | 'seleniumSessionId',
|
39 | 'webDriverProxy',
|
40 | 'useBlockingProxy',
|
41 | 'blockingProxyUrl',
|
42 | 'sauceUser',
|
43 | 'sauceKey',
|
44 | 'sauceAgent',
|
45 | 'sauceBuild',
|
46 | 'sauceSeleniumUseHttp',
|
47 | 'sauceSeleniumAddress',
|
48 | 'browserstackUser',
|
49 | 'browserstackKey',
|
50 | 'browserstackProxy',
|
51 | 'kobitonUser',
|
52 | 'kobitonKey',
|
53 | 'testobjectUser',
|
54 | 'testobjectKey',
|
55 | 'directConnect',
|
56 | 'firefoxPath',
|
57 | 'noGlobals',
|
58 | 'specs',
|
59 | 'exclude',
|
60 | 'suites',
|
61 | 'suite',
|
62 | 'capabilities',
|
63 | 'multiCapabilities',
|
64 | 'getMultiCapabilities',
|
65 | 'maxSessions',
|
66 | 'verbose',
|
67 | 'verboseMultiSessions',
|
68 | 'baseUrl',
|
69 | 'rootElement',
|
70 | 'allScriptsTimeout',
|
71 | 'getPageTimeout',
|
72 | 'beforeLaunch',
|
73 | 'onPrepare',
|
74 | 'onComplete',
|
75 | 'onCleanUp',
|
76 | 'afterLaunch',
|
77 | 'params',
|
78 | 'resultJsonOutputFile',
|
79 | 'restartBrowserBetweenTests',
|
80 | 'untrackOutstandingTimeouts',
|
81 | 'ignoreUncaughtExceptions',
|
82 | 'framework',
|
83 | 'jasmineNodeOpts',
|
84 | 'mochaOpts',
|
85 | 'plugins',
|
86 | 'skipSourceMapSupport',
|
87 | 'disableEnvironmentOverrides',
|
88 | 'ng12Hybrid',
|
89 | 'seleniumArgs',
|
90 | 'jvmArgs',
|
91 | 'configDir',
|
92 | 'troubleshoot',
|
93 | 'seleniumPort',
|
94 | 'mockSelenium',
|
95 | 'v8Debug',
|
96 | 'nodeDebug',
|
97 | 'debuggerServerPort',
|
98 | 'frameworkPath',
|
99 | 'elementExplorer',
|
100 | 'debug',
|
101 | 'logLevel',
|
102 | 'disableChecks',
|
103 | 'browser',
|
104 | 'name',
|
105 | 'platform',
|
106 | 'platform-version',
|
107 | 'tags',
|
108 | 'build',
|
109 | 'grep',
|
110 | 'invert-grep',
|
111 | 'explorer',
|
112 | 'stackTrace'
|
113 | ];
|
114 | let yargsOptions = {
|
115 | describes: {
|
116 | help: 'Print Protractor help menu',
|
117 | version: 'Print Protractor version',
|
118 | browser: 'Browsername, e.g. chrome or firefox',
|
119 | seleniumAddress: 'A running selenium address to use',
|
120 | seleniumSessionId: 'Attaching an existing session id',
|
121 | seleniumServerJar: 'Location of the standalone selenium jar file',
|
122 | seleniumPort: 'Optional port for the selenium standalone server',
|
123 | baseUrl: 'URL to prepend to all relative paths',
|
124 | rootElement: 'Element housing ng-app, if not html or body',
|
125 | specs: 'Comma-separated list of files to test',
|
126 | exclude: 'Comma-separated list of files to exclude',
|
127 | verbose: 'Print full spec names',
|
128 | stackTrace: 'Print stack trace on error',
|
129 | params: 'Param object to be passed to the tests',
|
130 | framework: 'Test framework to use: jasmine, mocha, or custom',
|
131 | resultJsonOutputFile: 'Path to save JSON test result',
|
132 | troubleshoot: 'Turn on troubleshooting output',
|
133 | elementExplorer: 'Interactively test Protractor commands',
|
134 | debuggerServerPort: 'Start a debugger server at specified port instead of repl',
|
135 | disableChecks: 'Disable cli checks',
|
136 | logLevel: 'Define Protractor log level [ERROR, WARN, INFO, DEBUG]'
|
137 | },
|
138 | aliases: {
|
139 | browser: 'capabilities.browserName',
|
140 | name: 'capabilities.name',
|
141 | platform: 'capabilities.platform',
|
142 | 'platform-version': 'capabilities.version',
|
143 | tags: 'capabilities.tags',
|
144 | build: 'capabilities.build',
|
145 | grep: 'jasmineNodeOpts.grep',
|
146 | 'invert-grep': 'jasmineNodeOpts.invertGrep',
|
147 | explorer: 'elementExplorer'
|
148 | },
|
149 | strings: { 'capabilities.tunnel-identifier': '' }
|
150 | };
|
151 | yargs.usage('Usage: protractor [configFile] [options]\n' +
|
152 | 'configFile defaults to protractor.conf.js\n' +
|
153 | 'The [options] object will override values from the config file.\n' +
|
154 | 'See the reference config for a full list of options.');
|
155 | for (let key of Object.keys(yargsOptions.describes)) {
|
156 | yargs.describe(key, yargsOptions.describes[key]);
|
157 | }
|
158 | for (let key of Object.keys(yargsOptions.aliases)) {
|
159 | yargs.alias(key, yargsOptions.aliases[key]);
|
160 | }
|
161 | for (let key of Object.keys(yargsOptions.strings)) {
|
162 | yargs.string(key);
|
163 | }
|
164 | yargs.check(function (arg) {
|
165 | if (arg._.length > 1) {
|
166 | throw new Error('Error: more than one config file specified');
|
167 | }
|
168 | return true;
|
169 | });
|
170 | let argv = yargs.parse(args);
|
171 | if (argv.help) {
|
172 | yargs.showHelp();
|
173 | process.exit(0);
|
174 | }
|
175 | if (argv.version) {
|
176 | console.log('Version ' + require(path.resolve(__dirname, '../package.json')).version);
|
177 | process.exit(0);
|
178 | }
|
179 |
|
180 | argv.unknownFlags_ = Object.keys(argv).filter((element) => {
|
181 | return element !== '$0' && element !== '_' && allowedNames.indexOf(element) === -1;
|
182 | });
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 | function processFilePatterns_(list) {
|
191 | return list.split(',').map(function (spec) {
|
192 | return path.resolve(process.cwd(), spec);
|
193 | });
|
194 | }
|
195 | ;
|
196 | if (argv.specs) {
|
197 | argv.specs = processFilePatterns_(argv.specs);
|
198 | }
|
199 | if (argv.exclude) {
|
200 | argv.exclude = processFilePatterns_(argv.exclude);
|
201 | }
|
202 | if (argv.capabilities && argv.capabilities.chromeOptions) {
|
203 |
|
204 |
|
205 |
|
206 | ['args', 'extensions', 'excludeSwitches', 'windowTypes'].forEach((key) => {
|
207 | if (typeof argv.capabilities.chromeOptions[key] === 'string') {
|
208 | argv.capabilities.chromeOptions[key] = [argv.capabilities.chromeOptions[key]];
|
209 | }
|
210 | });
|
211 | }
|
212 |
|
213 | let configFile = argv._[0];
|
214 | if (!configFile) {
|
215 | if (fs.existsSync('./protractor.conf.js')) {
|
216 | configFile = './protractor.conf.js';
|
217 | }
|
218 | }
|
219 | if (!configFile && !argv.elementExplorer && args.length < 3) {
|
220 | console.log('**you must either specify a configuration file ' +
|
221 | 'or at least 3 options. See below for the options:\n');
|
222 | yargs.showHelp();
|
223 | process.exit(1);
|
224 | }
|
225 |
|
226 | const launcher = require("./launcher");
|
227 | launcher.init(configFile, argv);
|
228 |
|
\ | No newline at end of file |