UNPKG

24.2 kBTypeScriptView Raw
1import { WebDriver } from 'selenium-webdriver';
2import { PluginConfig } from './plugins';
3export interface Config {
4 [key: string]: any;
5 /**
6 * The location of the standalone Selenium Server jar file, relative
7 * to the location of webdriver-manager. If no other method of starting
8 * Selenium Server is found, this will default to
9 * node_modules/protractor/node_modules/webdriver-manager/selenium/<jar file>
10 */
11 seleniumServerJar?: string;
12 /**
13 * The timeout milliseconds waiting for a local standalone Selenium Server to start.
14 *
15 * default: 30000ms
16 */
17 seleniumServerStartTimeout?: number;
18 /**
19 * Can be an object which will be passed to the SeleniumServer class as args.
20 * See a full list of options at
21 * https://github.com/SeleniumHQ/selenium/blob/master/javascript/node/selenium-webdriver/remote/index.js
22 * If you specify `args` or `port` in this object, it will overwrite the
23 * values set via the deprecated config values `seleniumPort` and
24 * `seleniumArgs`.
25 */
26 localSeleniumStandaloneOpts?: {
27 /**
28 * The port to start the Selenium Server on, or null if the server should
29 * find its own unused port.
30 */
31 port?: any;
32 /**
33 * Additional command line options to pass to selenium. For example,
34 * if you need to change the browser timeout, use
35 * seleniumArgs: ['-browserTimeout=60']
36 */
37 args?: any;
38 /**
39 * Additional command line jvm options to pass to selenium. For example,
40 * if you need to change the browser driver, use
41 * jvmArgs: ['-Dwebdriver.ie.driver=IEDriverServer_Win32_2.53.1.exe']
42 */
43 jvmArgs?: string[];
44 };
45 /**
46 * ChromeDriver location is used to help find the chromedriver binary. This will be passed to the
47 * Selenium jar as the system property webdriver.chrome.driver. If the value is not set when
48 * launching locally, it will use the default values downloaded from webdriver-manager.
49 *
50 * example:
51 * chromeDriver: './node_modules/webdriver-manager/selenium/chromedriver_2.20'
52 */
53 chromeDriver?: string;
54 /**
55 * geckoDriver location is used to help find the gecko binary. This will be passed to the Selenium
56 * jar as the system property webdriver.gecko.driver. If the value is not set when launching
57 * locally, it will use the default values downloaded from webdriver-manager.
58 */
59 geckoDriver?: string;
60 /**
61 * The address of a running Selenium Server. If specified, Protractor will
62 * connect to an already running instance of Selenium. This usually looks like
63 * seleniumAddress: 'http://localhost:4444/wd/hub'
64 */
65 seleniumAddress?: string;
66 /**
67 * The selenium session id allows Protractor to attach to an existing selenium
68 * browser session. The selenium session is maintained after the test has
69 * completed. Ignored if seleniumAddress is null.
70 */
71 seleniumSessionId?: string;
72 /**
73 * The address of a proxy server to use for communicating to Sauce Labs REST APIs via the
74 * saucelabs node module. For example, the Sauce Labs Proxy can be setup with: sauceProxy:
75 * 'http://localhost:3128'
76 */
77 sauceProxy?: string;
78 /**
79 * The proxy address that WebDriver (e.g. Selenium commands) traffic will go through
80 * which is tied to the browser session.
81 */
82 webDriverProxy?: string;
83 /**
84 * If specified, connect to webdriver through a proxy that manages client-side
85 * synchronization. Blocking Proxy is an experimental feature and may change
86 * without notice.
87 */
88 useBlockingProxy?: boolean;
89 /**
90 * If specified, Protractor will connect to the Blocking Proxy at the given
91 * url instead of starting it's own.
92 */
93 blockingProxyUrl?: string;
94 /**
95 * If the sauceUser and sauceKey are specified, seleniumServerJar will be
96 * ignored. The tests will be run remotely using Sauce Labs.
97 */
98 sauceUser?: string;
99 /**
100 * If the sauceUser and sauceKey are specified, seleniumServerJar will be
101 * ignored. The tests will be run remotely using Sauce Labs.
102 */
103 sauceKey?: string;
104 /**
105 * If you run your tests on SauceLabs you can specify the region you want to run your tests
106 * in via the `sauceRegion` property. Available short handles for regions are:
107 * us: us-west-1 (default)
108 * eu: eu-central-1
109 */
110 sauceRegion?: string;
111 /**
112 * Use sauceAgent if you need custom HTTP agent to connect to saucelabs.com APIs.
113 * This is needed if your computer is behind a corporate proxy.
114 *
115 * To match sauce agent implementation, use
116 * [HttpProxyAgent](https://github.com/TooTallNate/node-http-proxy-agent)
117 * to generate the agent or use sauceProxy as an alternative. If a
118 * sauceProxy is provided, the sauceAgent will be overridden.
119 */
120 sauceAgent?: any;
121 /**
122 * Use sauceBuild if you want to group test capabilites by a build ID
123 */
124 sauceBuild?: string;
125 /**
126 * If true, Protractor will use http:// protocol instead of https:// to
127 * connect to Sauce Labs defined by sauceSeleniumAddress.
128 *
129 * default: false
130 */
131 sauceSeleniumUseHttp?: boolean;
132 /**
133 * Use sauceSeleniumAddress if you need to customize the URL Protractor
134 * uses to connect to sauce labs (for example, if you are tunneling selenium
135 * traffic through a sauce connect tunnel). Default is
136 * ondemand.saucelabs.com:443/wd/hub
137 */
138 sauceSeleniumAddress?: string;
139 /**
140 * If testobjectUser and testobjectKey are specified, kobitonUser, kobitonKey, browserstackUser,
141 * browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
142 * TestObject.
143 */
144 testobjectUser?: string;
145 /**
146 * If testobjectUser and testobjectKey are specified, kobitonUser, kobitonKey, browserStackUser,
147 * browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
148 * TestObject.
149 */
150 testobjectKey?: string;
151 /**
152 * If kobitonUser and kobitonKey are specified, testobjectUser, testojbectKey, browserstackUser,
153 * browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
154 * TestObject.
155 */
156 kobitonUser?: string;
157 /**
158 * If kobitonUser and kobitonKey are specified, testobjectUser, testojbectKey, browserStackUser,
159 * browserStackKey and seleniumServerJar will be ignored. The tests will be run remotely using
160 * TestObject.
161 */
162 kobitonKey?: string;
163 /**
164 * If browserstackUser and browserstackKey are specified, seleniumServerJar
165 * will be ignored. The tests will be run remotely using BrowserStack.
166 */
167 browserstackUser?: string;
168 /**
169 * If browserstackUser and browserstackKey are specified, seleniumServerJar
170 * will be ignored. The tests will be run remotely using BrowserStack.
171 */
172 browserstackKey?: string;
173 /**
174 * Proxy server to be used for connecting to BrowserStack APIs
175 * e.g. "http://proxy.example.com:1234".
176 * This should be used when you are behind a proxy server.
177 */
178 browserstackProxy?: string;
179 /**
180 * If true, Protractor will connect directly to the browser Drivers
181 * at the locations specified by chromeDriver and firefoxPath. Only Chrome
182 * and Firefox are supported for direct connect.
183 *
184 * default: false
185 */
186 directConnect?: boolean;
187 /**
188 * Path to the firefox application binary. If null, will attempt to find
189 * firefox in the default locations.
190 */
191 firefoxPath?: string;
192 seleniumWebDriver?: WebDriver;
193 /**
194 * Use default globals: 'protractor', 'browser', '$', '$$', 'element', 'by'.
195 * These also exist as properties of the protractor namespace:
196 * 'protractor.browser', 'protractor.$', 'protractor.$$',
197 * 'protractor.element', 'protractor.by', and 'protractor.By'.
198 *
199 * When no globals is set to true, the only available global variable will be
200 * 'protractor'.
201 */
202 noGlobals?: boolean;
203 /**
204 * Required. Spec patterns are relative to the location of this config.
205 *
206 * Example:
207 * specs: [
208 * 'spec/*_spec.js'
209 * ]
210 */
211 specs?: Array<string>;
212 /**
213 * Patterns to exclude specs.
214 */
215 exclude?: Array<string> | string;
216 /**
217 * Alternatively, suites may be used. When run without a command line
218 * parameter, all suites will run. If run with --suite=smoke or
219 * --suite=smoke,full only the patterns matched by the specified suites will
220 * run.
221 *
222 * Example:
223 * suites: {
224 * smoke: 'spec/smoketests/*.js',
225 * full: 'spec/*.js'
226 * }
227 */
228 suites?: any;
229 /**
230 * If you would like protractor to use a specific suite by default instead of
231 * all suites, you can put that in the config file as well.
232 */
233 suite?: string;
234 /**
235 * Protractor can launch your tests on one or more browsers. If you are
236 * testing on a single browser, use the capabilities option. If you are
237 * testing on multiple browsers, use the multiCapabilities array.
238 *
239 * For a list of available capabilities, see
240 * https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities
241 * In addition, you may specify count, shardTestFiles, and maxInstances.
242 *
243 * Example:
244 * capabilities: {
245 * browserName: 'chrome',
246 * name: 'Unnamed Job',
247 * logName: 'Chrome - English',
248 * count: 1,
249 * shardTestFiles: false,
250 * maxInstances: 1,
251 * specs: ['spec/chromeOnlySpec.js'],
252 * exclude: ['spec/doNotRunInChromeSpec.js'],
253 * seleniumAddress: 'http://localhost:4444/wd/hub'
254 * }
255 */
256 capabilities?: {
257 [key: string]: any;
258 browserName?: string;
259 /**
260 * Name of the process executing this capability. Not used directly by
261 * protractor or the browser, but instead pass directly to third parties
262 * like BrowserStack and SauceLabs as the name of the job running this
263 * test
264 */
265 name?: string;
266 /**
267 * User defined name for the capability that will display in the results
268 * log. Defaults to the browser name
269 */
270 logName?: string;
271 /**
272 * Number of times to run this set of capabilities (in parallel, unless
273 * limited by maxSessions). Default is 1.
274 */
275 count?: number;
276 /**
277 * If this is set to be true, specs will be sharded by file (i.e. all
278 * files to be run by this set of capabilities will run in parallel).
279 * Default is false.
280 */
281 shardTestFiles?: boolean;
282 /**
283 * Maximum number of browser instances that can run in parallel for this
284 * set of capabilities. This is only needed if shardTestFiles is true.
285 * Default is 1.
286 */
287 maxInstances?: number;
288 /**
289 * Additional spec files to be run on this capability only.
290 */
291 specs?: string[];
292 /**
293 * Spec files to be excluded on this capability only.
294 */
295 exclude?: string[];
296 /**
297 * Optional: override global seleniumAddress on this capability only.
298 */
299 seleniumAddress?: string;
300 };
301 /**
302 * If you would like to run more than one instance of WebDriver on the same
303 * tests, use multiCapabilities, which takes an array of capabilities.
304 * If this is specified, capabilities will be ignored.
305 */
306 multiCapabilities?: Array<any>;
307 /**
308 * If you need to resolve multiCapabilities asynchronously (i.e. wait for
309 * server/proxy, set firefox profile, etc), you can specify a function here
310 * which will return either `multiCapabilities` or a promise to
311 * `multiCapabilities`.
312 *
313 * If this returns a promise, it is resolved immediately after
314 * `beforeLaunch` is run, and before any driver is set up. If this is
315 * specified, both capabilities and multiCapabilities will be ignored.
316 */
317 getMultiCapabilities?: any;
318 /**
319 * Maximum number of total browser sessions to run. Tests are queued in
320 * sequence if number of browser sessions is limited by this parameter.
321 * Use a number less than 1 to denote unlimited. Default is unlimited.
322 */
323 maxSessions?: number;
324 /**
325 * Whether or not to buffer output when running tests on multiple browsers
326 * in parallel. By default, when running multiple browser sessions, the
327 * results are buffered and not logged until the test run finishes. If true,
328 * when running multiple sessions in parallel results will be logged when
329 * each test finishes.
330 */
331 verboseMultiSessions?: boolean;
332 /**
333 * A base URL for your application under test. Calls to protractor.get()
334 * with relative paths will be resolved against this URL (via url.resolve)
335 */
336 baseUrl?: string;
337 /**
338 * A CSS Selector for a DOM element within your Angular application.
339 * Protractor will attempt to automatically find your application, but it is
340 * necessary to set rootElement in certain cases.
341 *
342 * In Angular 1, Protractor will use the element your app bootstrapped to by
343 * default. If that doesn't work, it will then search for hooks in `body` or
344 * `ng-app` elements (details here: https://git.io/v1b2r).
345 *
346 * In later versions of Angular, Protractor will try to hook into all angular
347 * apps on the page. Use rootElement to limit the scope of which apps
348 * Protractor waits for and searches within.
349 */
350 rootElement?: string;
351 /**
352 * The timeout in milliseconds for each script run on the browser. This
353 * should be longer than the maximum time your application needs to
354 * stabilize between tasks.
355 */
356 allScriptsTimeout?: number;
357 /**
358 * How long to wait for a page to load.
359 */
360 getPageTimeout?: number;
361 /**
362 * A callback function called once configs are read but before any
363 * environment setup. This will only run once, and before onPrepare.
364 *
365 * You can specify a file containing code to run by setting beforeLaunch to
366 * the filename string.
367 *
368 * At this point, global variable 'protractor' object will NOT be set up,
369 * and globals from the test framework will NOT be available. The main
370 * purpose of this function should be to bring up test dependencies.
371 */
372 beforeLaunch?: () => void;
373 /**
374 * A callback function called once protractor is ready and available, and
375 * before the specs are executed. If multiple capabilities are being run,
376 * this will run once per capability.
377 *
378 * You can specify a file containing code to run by setting onPrepare to
379 * the filename string. onPrepare can optionally return a promise, which
380 * Protractor will wait for before continuing execution. This can be used if
381 * the preparation involves any asynchronous calls, e.g. interacting with
382 * the browser. Otherwise Protractor cannot guarantee order of execution
383 * and may start the tests before preparation finishes.
384 *
385 * At this point, global variable 'protractor' object will be set up, and
386 * globals from the test framework will be available. For example, if you
387 * are using Jasmine, you can add a reporter with:
388 *
389 * jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter(
390 * 'outputdir/', true, true));
391 *
392 * If you need access back to the current configuration object,
393 * use a pattern like the following:
394 *
395 * return browser.getProcessedConfig().then(function(config) {
396 * // config.capabilities is the CURRENT capability being run, if
397 * // you are using multiCapabilities.
398 * console.log('Executing capability', config.capabilities);
399 * });
400 */
401 onPrepare?: () => void;
402 /**
403 * A callback function called once tests are finished. onComplete can
404 * optionally return a promise, which Protractor will wait for before
405 * shutting down webdriver.
406 *
407 * At this point, tests will be done but global objects will still be
408 * available.
409 */
410 onComplete?: () => void;
411 /**
412 * A callback function called once the tests have finished running and
413 * the WebDriver instance has been shut down. It is passed the exit code
414 * (0 if the tests passed). This is called once per capability.
415 */
416 onCleanUp?: (exitCode: number) => void;
417 /**
418 * A callback function called once all tests have finished running and
419 * the WebDriver instance has been shut down. It is passed the exit code
420 * (0 if the tests passed). afterLaunch must return a promise if you want
421 * asynchronous code to be executed before the program exits.
422 * This is called only once before the program exits (after onCleanUp).
423 */
424 afterLaunch?: (exitCode: number) => void;
425 /**
426 * The params object will be passed directly to the Protractor instance,
427 * and can be accessed from your test as browser.params. It is an arbitrary
428 * object and can contain anything you may need in your test.
429 * This can be changed via the command line as:
430 * --params.login.user "Joe"
431 *
432 * Example:
433 * params: {
434 * login: {
435 * user: 'Jane',
436 * password: '1234'
437 * }
438 * }
439 */
440 params?: any;
441 /**
442 * If set, protractor will save the test output in json format at this path.
443 * The path is relative to the location of this config.
444 */
445 resultJsonOutputFile?: any;
446 /**
447 * If true, protractor will restart the browser between each test. Default
448 * value is false.
449 *
450 * CAUTION: This will cause your tests to slow down drastically.
451 */
452 restartBrowserBetweenTests?: boolean;
453 /**
454 * Protractor will track outstanding $timeouts by default, and report them
455 * in the error message if Protractor fails to synchronize with Angular in
456 * time. In order to do this Protractor needs to decorate $timeout.
457 *
458 * CAUTION: If your app decorates $timeout, you must turn on this flag. This
459 * is false by default.
460 */
461 untrackOutstandingTimeouts?: boolean;
462 /**
463 * If set, Protractor will ignore uncaught exceptions instead of exiting
464 * without an error code. The exceptions will still be logged as warnings.
465 */
466 ignoreUncaughtExceptions?: boolean;
467 /**
468 * If set, will create a log file in the given directory with a readable log of
469 * the webdriver commands it executes.
470 *
471 * This is an experimental feature. Enabling this will also turn on Blocking Proxy
472 * synchronization, which is also experimental.
473 */
474 webDriverLogDir?: string;
475 /**
476 * If set, Protractor will pause the specified amount of time (in milliseconds)
477 * before interactions with browser elements (ie, sending keys, clicking). It will
478 * also highlight the element it's about to interact with.
479 *
480 * This is an experimental feature. Enabling this will also turn on Blocking Proxy
481 * synchronization, which is also experimental.
482 */
483 highlightDelay?: number;
484 /**
485 * Protractor log level
486 *
487 * default: INFO
488 */
489 logLevel?: 'ERROR' | 'WARN' | 'INFO' | 'DEBUG';
490 /**
491 * Test framework to use. This may be one of: jasmine, mocha or custom.
492 * Default value is 'jasmine'
493 *
494 * When the framework is set to "custom" you'll need to additionally
495 * set frameworkPath with the path relative to the config file or absolute:
496 *
497 * framework: 'custom',
498 * frameworkPath: './frameworks/my_custom_jasmine.js',
499 *
500 * See github.com/angular/protractor/blob/master/lib/frameworks/README.md
501 * to comply with the interface details of your custom implementation.
502 *
503 * Jasmine is fully supported as test and assertion frameworks.
504 * Mocha has limited support. You will need to include your
505 * own assertion framework (such as Chai) if working with Mocha.
506 */
507 framework?: string;
508 /**
509 * Options to be passed to jasmine.
510 *
511 * See https://github.com/jasmine/jasmine-npm/blob/master/lib/jasmine.js
512 * for the exact options available.
513 */
514 jasmineNodeOpts?: {
515 [key: string]: any;
516 /**
517 * If true, print colors to the terminal.
518 */
519 showColors?: boolean;
520 /**
521 * Default time to wait in ms before a test fails.
522 */
523 defaultTimeoutInterval?: number;
524 /**
525 * Function called to print jasmine results.
526 */
527 print?: () => void;
528 /**
529 * If set, only execute specs whose names match the pattern, which is
530 * internally compiled to a RegExp.
531 */
532 grep?: string;
533 /**
534 * Inverts 'grep' matches
535 */
536 invertGrep?: boolean;
537 /**
538 * If true, run specs in semi-random order
539 */
540 random?: boolean;
541 /**
542 * Set the randomization seed if randomization is turned on
543 */
544 seed?: string;
545 };
546 /**
547 * Options to be passed to Mocha.
548 *
549 * See the full list at http://mochajs.org/
550 */
551 mochaOpts?: {
552 [key: string]: any;
553 ui?: string;
554 reporter?: string;
555 };
556 /**
557 * See docs/plugins.md
558 */
559 plugins?: PluginConfig[];
560 /**
561 * Turns off source map support. Stops protractor from registering global
562 * variable `source-map-support`. Defaults to `false`
563 */
564 skipSourceMapSupport?: boolean;
565 /**
566 * Turns off WebDriver's environment variables overrides to ignore any
567 * environment variable and to only use the configuration in this file.
568 * Defaults to `false`
569 */
570 disableEnvironmentOverrides?: boolean;
571 /**
572 * Tells Protractor to interpret any angular apps it comes across as hybrid
573 * angular1/angular2 apps (i.e. apps using ngUpgrade)
574 * Defaults to `false`
575 *
576 * @type {boolean}
577 */
578 ng12Hybrid?: boolean;
579 /**
580 * Protractor will exit with an error if it sees any command line flags it doesn't
581 * recognize. Set disableChecks true to disable this check.
582 */
583 disableChecks?: boolean;
584 /**
585 * Enable/disable the WebDriver Control Flow.
586 *
587 * WebDriverJS (and by extention, Protractor) uses a Control Flow to manage the order in which
588 * commands are executed and promises are resolved (see docs/control-flow.md for details).
589 * However, as syntax like `async`/`await` are being introduced, WebDriverJS has decided to
590 * deprecate the control flow, and have users manage the asynchronous activity themselves
591 * (details here: https://github.com/SeleniumHQ/selenium/issues/2969).
592 *
593 * At the moment, the WebDriver Control Flow is still enabled by default. You can disable it by
594 * setting the environment variable `SELENIUM_PROMISE_MANAGER` to `0`. In a webdriver release in
595 * Q4 2017, the Control Flow will be disabled by default, but you will be able to re-enable it by
596 * setting `SELENIUM_PROMISE_MANAGER` to `1`. At a later point, the control flow will be removed
597 * for good.
598 *
599 * If you don't like managing environment variables, you can set this option in your config file,
600 * and Protractor will handle enabling/disabling the control flow for you. Setting this option
601 * is higher priority than the `SELENIUM_PROMISE_MANAGER` environment variable.
602 *
603 * @type {boolean=}
604 */
605 SELENIUM_PROMISE_MANAGER?: boolean;
606 seleniumArgs?: any[];
607 jvmArgs?: string[];
608 configDir?: string;
609 troubleshoot?: boolean;
610 seleniumPort?: number;
611 mockSelenium?: boolean;
612 v8Debug?: any;
613 nodeDebug?: boolean;
614 debuggerServerPort?: number;
615 frameworkPath?: string;
616 elementExplorer?: any;
617 debug?: boolean;
618 unknownFlags_?: string[];
619}