@oracle/oraclejet-webdriver 18.1.5 → 19.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/elements/oj-chart/OjChart.d.ts +1 -1
  2. package/elements/oj-chart/OjChart.js +1 -1
  3. package/elements/oj-chart/OjChartBase.d.ts +21 -0
  4. package/elements/oj-data-grid/OjDataGridBase.d.ts +27 -1
  5. package/elements/oj-data-grid/OjDataGridBase.js +18 -0
  6. package/elements/oj-data-grid/OjDataGridBase.js.map +1 -1
  7. package/elements/oj-input-time/OjInputTimeBase.d.ts +18 -7
  8. package/elements/oj-input-time/OjInputTimeBase.js +7 -7
  9. package/elements/oj-list-view/OjListView.d.ts +25 -0
  10. package/elements/oj-list-view/OjListView.js +28 -1
  11. package/elements/oj-list-view/OjListView.js.map +1 -1
  12. package/elements/oj-list-view/OjListViewBase.d.ts +23 -0
  13. package/elements/oj-n-box/OjNBoxBase.d.ts +3 -0
  14. package/elements/oj-spark-chart/OjSparkChartBase.d.ts +2 -2
  15. package/elements/oj-spark-chart/OjSparkChartBase.js +2 -2
  16. package/elements/oj-status-meter-gauge/OjStatusMeterGauge.d.ts +2 -2
  17. package/elements/oj-status-meter-gauge/OjStatusMeterGauge.js +2 -2
  18. package/elements/oj-stream-list/OjStreamListBase.d.ts +2 -2
  19. package/elements/oj-tab-bar/OjTabBar.d.ts +23 -0
  20. package/elements/oj-tab-bar/OjTabBar.js +41 -0
  21. package/elements/oj-tab-bar/OjTabBar.js.map +1 -1
  22. package/elements/oj-tab-bar/OjTabBarBase.d.ts +20 -0
  23. package/elements/oj-table/OjTableBase.d.ts +8 -0
  24. package/elements/oj-thematic-map/OjThematicMapBase.d.ts +11 -4
  25. package/elements/oj-timeline/OjTimelineBase.d.ts +3 -0
  26. package/elements/oj-waterfall-layout/OjWaterfallLayoutBase.d.ts +8 -1
  27. package/elements/oj-waterfall-layout/OjWaterfallLayoutBase.js +9 -0
  28. package/elements/oj-waterfall-layout/OjWaterfallLayoutBase.js.map +1 -1
  29. package/index.d.ts +4 -7
  30. package/index.js +37 -9
  31. package/index.js.map +1 -1
  32. package/lib/ScreenshotManager.js +35 -2
  33. package/lib/ScreenshotManager.js.map +1 -1
  34. package/lib/busy-context-utils.d.ts +1 -0
  35. package/lib/busy-context-utils.js +22 -2
  36. package/lib/busy-context-utils.js.map +1 -1
  37. package/lib/driver-manager.d.ts +1 -206
  38. package/lib/driver-manager.js +6 -314
  39. package/lib/driver-manager.js.map +1 -1
  40. package/lib/driver-override.js +38 -5
  41. package/lib/driver-override.js.map +1 -1
  42. package/lib/file-picker-utils.js +35 -2
  43. package/lib/file-picker-utils.js.map +1 -1
  44. package/package.json +36 -30
  45. package/src/elements/oj-chart/OjChart.ts +1 -1
  46. package/src/elements/oj-chart/OjChartBase.ts +21 -0
  47. package/src/elements/oj-data-grid/OjDataGridBase.ts +33 -1
  48. package/src/elements/oj-input-time/OjInputTimeBase.ts +18 -7
  49. package/src/elements/oj-list-view/OjListView.ts +40 -1
  50. package/src/elements/oj-list-view/OjListViewBase.ts +23 -0
  51. package/src/elements/oj-n-box/OjNBoxBase.ts +3 -0
  52. package/src/elements/oj-spark-chart/OjSparkChartBase.ts +2 -2
  53. package/src/elements/oj-status-meter-gauge/OjStatusMeterGauge.ts +2 -2
  54. package/src/elements/oj-stream-list/OjStreamListBase.ts +2 -2
  55. package/src/elements/oj-tab-bar/OjTabBar.ts +57 -1
  56. package/src/elements/oj-tab-bar/OjTabBarBase.ts +20 -0
  57. package/src/elements/oj-table/OjTableBase.ts +8 -0
  58. package/src/elements/oj-thematic-map/OjThematicMapBase.ts +11 -4
  59. package/src/elements/oj-timeline/OjTimelineBase.ts +3 -0
  60. package/src/elements/oj-waterfall-layout/OjWaterfallLayoutBase.ts +11 -1
  61. package/src/index.ts +5 -12
  62. package/src/lib/busy-context-utils.ts +34 -3
  63. package/src/lib/driver-manager.ts +9 -350
  64. package/src/lib/driver-override.ts +7 -4
  65. package/tsconfig.json +2 -2
  66. package/wdtsdoc/assets/navigation.js +1 -1
  67. package/wdtsdoc/assets/search.js +1 -1
  68. package/wdtsdoc/classes/elements.OjChart.html +1 -1
  69. package/wdtsdoc/classes/elements.OjDataGrid.html +11 -3
  70. package/wdtsdoc/classes/elements.OjInputTime.html +26 -19
  71. package/wdtsdoc/classes/elements.OjListView.html +13 -2
  72. package/wdtsdoc/classes/elements.OjSparkChart.html +7 -5
  73. package/wdtsdoc/classes/elements.OjStatusMeterGauge.html +2 -2
  74. package/wdtsdoc/classes/elements.OjTabBar.html +15 -2
  75. package/wdtsdoc/classes/elements.OjWaterfallLayout.html +6 -2
  76. package/wdtsdoc/classes/elements._internal_.OjDataGridBase.html +10 -2
  77. package/wdtsdoc/classes/elements._internal_.OjInputTimeBase.html +26 -19
  78. package/wdtsdoc/classes/elements._internal_.OjSparkChartBase.html +7 -5
  79. package/wdtsdoc/classes/elements._internal_.OjWaterfallLayoutBase.html +6 -2
  80. package/wdtsdoc/classes/index.DriverManager.html +19 -9
  81. package/wdtsdoc/interfaces/elements._internal_.Areas.html +7 -5
  82. package/wdtsdoc/interfaces/elements._internal_.DndDropRows-1.html +3 -1
  83. package/wdtsdoc/interfaces/elements._internal_.Item.html +5 -3
  84. package/wdtsdoc/interfaces/elements._internal_.Links.html +7 -5
  85. package/wdtsdoc/interfaces/elements._internal_.LinksEndLocation.html +2 -2
  86. package/wdtsdoc/interfaces/elements._internal_.LinksStartLocation.html +2 -2
  87. package/wdtsdoc/interfaces/elements._internal_.MajorAxis-1.html +4 -3
  88. package/wdtsdoc/interfaces/elements._internal_.Markers.html +7 -5
  89. package/wdtsdoc/interfaces/elements._internal_.MinorAxis-1.html +4 -3
  90. package/wdtsdoc/interfaces/elements._internal_.Overview-2.html +4 -3
  91. package/wdtsdoc/interfaces/elements._internal_.PickerAttributes-6.html +3 -2
  92. package/wdtsdoc/interfaces/elements._internal_.ScrollPosition-3.html +2 -2
  93. package/wdtsdoc/interfaces/elements._internal_.ScrollPosition-5.html +1 -1
  94. package/wdtsdoc/interfaces/elements._internal_.StyleDefaults-4.html +4 -3
  95. package/wdtsdoc/interfaces/elements._internal_.StyleDefaults.html +5 -1
  96. package/wdtsdoc/interfaces/elements._internal_.StyleDefaultsCellDefaults.html +11 -8
  97. package/wdtsdoc/interfaces/elements._internal_.TimePicker-2.html +7 -5
  98. package/wdtsdoc/interfaces/elements._internal_.Translations-20.html +27 -19
  99. package/wdtsdoc/interfaces/elements._internal_.Translations-24.html +58 -39
  100. package/wdtsdoc/interfaces/elements._internal_.Translations-48.html +13 -1
  101. package/wdtsdoc/interfaces/elements._internal_.Translations-49.html +3 -1
  102. package/wdtsdoc/interfaces/elements._internal_.Translations-7.html +8 -2
  103. package/wdtsdoc/interfaces/elements._internal_.Translations.html +5 -2
  104. package/wdtsdoc/interfaces/elements._internal_.ValueFormatsLabel.html +5 -1
  105. package/wdtsdoc/interfaces/{index._internal_.CapabilitiesConfiguration.html → index.DriverConfiguration.html} +4 -4
  106. package/wdtsdoc/interfaces/index._internal_.BufferConstructor.html +1 -1
  107. package/wdtsdoc/interfaces/index._internal_.ZlibOptions.html +1 -1
  108. package/wdtsdoc/modules/index._internal_.html +0 -1
  109. package/wdtsdoc/modules/index.html +2 -1
  110. package/lib/version-check.d.ts +0 -11
  111. package/lib/version-check.js +0 -32
  112. package/lib/version-check.js.map +0 -1
  113. package/src/lib/version-check.ts +0 -38
@@ -173,11 +173,31 @@ export interface Translations {
173
173
  * @deprecated Since 18.0.0. The Redwood design system does not allow this to be customized.
174
174
  */
175
175
  accessibleReorderTouchInstructionText: string;
176
+ /**
177
+ * Provides properties to customize the default context menu item's aria-label
178
+ * @deprecated Since 19.0.0. The Redwood design system does not allow this to be customized.
179
+ */
180
+ labelActions: string;
181
+ /**
182
+ * The context menu description text used for aria describedby by tabbar.
183
+ * @deprecated Since 19.0.0. The Redwood design system does not allow this to be customized.
184
+ */
185
+ labelContextMenu: string;
176
186
  /**
177
187
  * Provides properties to customize the context menu cut label.
178
188
  * @deprecated Since 18.0.0. The Redwood design system does not allow this to be customized.
179
189
  */
180
190
  labelCut: string;
191
+ /**
192
+ * The context menu move left label.
193
+ * @deprecated Since 19.0.0. The Redwood design system does not allow this to be customized.
194
+ */
195
+ labelMoveLeft: string;
196
+ /**
197
+ * The context menu move right label.
198
+ * @deprecated Since 19.0.0. The Redwood design system does not allow this to be customized.
199
+ */
200
+ labelMoveRight: string;
181
201
  /**
182
202
  * Provides properties to customize the context menu paste after label.
183
203
  * @deprecated Since 18.0.0. The Redwood design system does not allow this to be customized.
@@ -581,6 +581,10 @@ export interface DndDropRows {
581
581
  * A data type or an array of data types this element can accept.
582
582
  */
583
583
  dataTypes: string | Array<string>;
584
+ /**
585
+ * The drop positions this Table supports. Default is ['before'].
586
+ */
587
+ positions: Array<unknown | unknown>;
584
588
  }
585
589
  export interface DndReorder {
586
590
  /**
@@ -866,4 +870,8 @@ export interface Translations {
866
870
  * Used for the default required icon tooltip.
867
871
  */
868
872
  tooltipRequired: string;
873
+ /**
874
+ * Used for the separators in the default header tooltip.
875
+ */
876
+ tooltipSeparator: string;
869
877
  }
@@ -386,10 +386,12 @@ export interface Areas {
386
386
  shortDesc: string | null;
387
387
  /**
388
388
  * The CSS style class defining the style of the area.
389
+ * @deprecated Since 19.0.0. The svgClassName property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
389
390
  */
390
391
  svgClassName: string;
391
392
  /**
392
393
  * The CSS style object defining the style of the area. Only SVG CSS style properties are supported.
394
+ * @deprecated Since 19.0.0. The svgStyle property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
393
395
  */
394
396
  svgStyle: object;
395
397
  }
@@ -424,10 +426,12 @@ export interface Links {
424
426
  startLocation: LinksStartLocation;
425
427
  /**
426
428
  * The CSS style class defining the style of the link.
429
+ * @deprecated Since 19.0.0. The svgClassName property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
427
430
  */
428
431
  svgClassName: string;
429
432
  /**
430
433
  * The CSS style object defining the style of the link. Only SVG CSS style properties are supported.
434
+ * @deprecated Since 19.0.0. The svgStyle property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
431
435
  */
432
436
  svgStyle: object;
433
437
  /**
@@ -445,11 +449,11 @@ export interface LinksEndLocation {
445
449
  */
446
450
  location: string;
447
451
  /**
448
- * The x coordinate which can represent latitude of the end point.
452
+ * The x coordinate which can represent longitude of the end point.
449
453
  */
450
454
  x: number;
451
455
  /**
452
- * The y coordinate which can represent longitude of the end point.
456
+ * The y coordinate which can represent latitude of the end point.
453
457
  */
454
458
  y: number;
455
459
  }
@@ -463,11 +467,11 @@ export interface LinksStartLocation {
463
467
  */
464
468
  location: string;
465
469
  /**
466
- * The x coordinate which can represent latitude of the start point.
470
+ * The x coordinate which can represent longitude of the start point.
467
471
  */
468
472
  x: number;
469
473
  /**
470
- * The y coordinate which can represent longitude of the start point.
474
+ * The y coordinate which can represent latitude of the start point.
471
475
  */
472
476
  y: number;
473
477
  }
@@ -578,10 +582,12 @@ export interface Markers {
578
582
  sourceSelected: string;
579
583
  /**
580
584
  * The CSS style class defining the style of the marker.
585
+ * @deprecated Since 19.0.0. The svgClassName property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
581
586
  */
582
587
  svgClassName: string;
583
588
  /**
584
589
  * The CSS style object defining the style of the marker. Only SVG CSS style properties are supported.
590
+ * @deprecated Since 19.0.0. The svgStyle property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
585
591
  */
586
592
  svgStyle: object;
587
593
  /**
@@ -604,6 +610,7 @@ export interface Markers {
604
610
  export interface StyleDefaults {
605
611
  /**
606
612
  * The CSS style object defining the style of the area layer areas.
613
+ * @deprecated Since 19.0.0. The areaSvgStyle property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
607
614
  */
608
615
  areaSvgStyle: object;
609
616
  /**
@@ -270,6 +270,7 @@ export interface MajorAxis {
270
270
  scale: string;
271
271
  /**
272
272
  * The CSS style object defining any additional styling of the major axis.
273
+ * @deprecated Since 19.0.0. The svgStyle property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
273
274
  */
274
275
  svgStyle: object;
275
276
  }
@@ -322,6 +323,7 @@ export interface MinorAxis {
322
323
  scale: string;
323
324
  /**
324
325
  * The CSS style object defining any additional styling of the minor axis.
326
+ * @deprecated Since 19.0.0. The svgStyle property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
325
327
  */
326
328
  svgStyle: object;
327
329
  /**
@@ -374,6 +376,7 @@ export interface Overview {
374
376
  rendered: string;
375
377
  /**
376
378
  * The CSS style object defining any additional styling of the overview.
379
+ * @deprecated Since 19.0.0. The svgStyle property is deprecated. This API is not recommended in Redwood theme. Use other customization APIs where appropriate.
377
380
  */
378
381
  svgStyle: object;
379
382
  }
@@ -7,6 +7,16 @@ import { OjWebElement } from '../';
7
7
  * Put overrides into the WebElements's subclass, OjWaterfallLayout.ts.
8
8
  */
9
9
  export class OjWaterfallLayoutBase extends OjWebElement {
10
+ /**
11
+ * Gets the value of <code>cardSizing</code> property.
12
+ * Specifies whether the card size stays the same or can change dynamically during runtime. See the Help documentation for more information.
13
+ * @return The value of <code>cardSizing</code> property.
14
+ *
15
+ */
16
+ public getCardSizing(): Promise<string> {
17
+ return this.getProperty<string>('cardSizing');
18
+ }
19
+
10
20
  /**
11
21
  * Gets the value of <code>scrollPolicy</code> property.
12
22
  * Specifies how data are fetched as user scrolls towards the bottom of the grid.
@@ -69,7 +79,7 @@ export interface ScrollPosition {
69
79
  /**
70
80
  * The key of the item. If DataProvider is used for data and the key does not exist in the DataProvider or if the item has not been fetched yet, then the value is ignored.
71
81
  */
72
- key: any;
82
+ key: string | number;
73
83
  /**
74
84
  * The vertical offset in pixels relative to the item identified by key.
75
85
  */
package/src/index.ts CHANGED
@@ -19,22 +19,16 @@ import {
19
19
  OjFetch
20
20
  } from './lib/OjFetch';
21
21
 
22
- import { checkVersions } from './lib/version-check';
23
- import { Expectation } from './lib/Expectation';
24
- import * as sm from './lib/ScreenshotManager';
25
22
  import { getBusyStates, pageReady } from './lib/busy-context-utils';
26
23
  import { assertViewModelValue } from './lib/viewmodel-utils';
27
24
  import { isNoRequireJet, setNoRequireJet } from './lib/no-require-jet';
28
25
 
29
- // Export register function before importing elements so that they can
30
- // call it to register themselves
31
26
  export { fetchKeyByFilter } from './lib/dataprovider-utils';
32
- export { DriverManager } from './lib/driver-manager';
27
+ export { DriverManager, type DriverConfiguration } from './lib/driver-manager';
33
28
  export { register } from './lib/driver-override';
34
- export type { SlotProxy } from './lib/slot-proxy';
35
- export { slotProxy } from './lib/slot-proxy';
36
- export { sm as ScreenshotManager };
37
- export { Expectation };
29
+ export { type SlotProxy, slotProxy } from './lib/slot-proxy';
30
+ export * as ScreenshotManager from './lib/ScreenshotManager';
31
+ export { Expectation } from './lib/Expectation';
38
32
 
39
33
  /**
40
34
  * This interface describes the functions that are needed from the driver object
@@ -97,11 +91,10 @@ const ojwd = {
97
91
  const timeouts = await driver.manage().getTimeouts();
98
92
  try {
99
93
  await driver.wait(pageReady(), timeouts.pageLoad);
100
- await checkVersions(driver);
101
94
  } catch (ex) {
102
95
  if (ex instanceof error.TimeoutError || ex instanceof error.ScriptTimeoutError) {
103
96
  const openStates = await getBusyStates(driver);
104
- ex.message += ` - open busy states: ${openStates}`;
97
+ ex.message += `\nBusy states: ${openStates}`;
105
98
  }
106
99
  throw ex;
107
100
  }
@@ -1,5 +1,9 @@
1
1
  import { Condition, WebDriver, error } from 'selenium-webdriver';
2
2
  import { executeWithModules, TEST_OBJ_NAME } from './oj-module-proxy';
3
+ // the relative path to package.json is correct when run from dist/ folder
4
+ const wdPkg = require('../package.json');
5
+
6
+ type VersionDef = { version: string; revision: string };
3
7
 
4
8
  /**
5
9
  * Get open busy state descriptions from the page context
@@ -11,7 +15,10 @@ export const getBusyStates = async (driver: WebDriver): Promise<string> => {
11
15
  const hasProxy = await driver.executeScript<boolean>(`return '${TEST_OBJ_NAME}' in window`);
12
16
  if (hasProxy) {
13
17
  return executeWithModules<string>(driver, ['BusyContext'], [], (BusyContext) =>
14
- BusyContext.getBusyStates().map((state: { description: string }) => state.description)
18
+ BusyContext.getBusyStates().map(
19
+ (state: { description: string; stack: string }) =>
20
+ `${state.description}${state.stack ? '\n' + state.stack : ''}`
21
+ )
15
22
  ).catch((ex) => ex.message);
16
23
  }
17
24
  return '';
@@ -21,18 +28,42 @@ export const getBusyStates = async (driver: WebDriver): Promise<string> => {
21
28
  * Returns a Promise that is resolved when the application's busy
22
29
  * state reports ready or the page is not a JET page (RequireJS
23
30
  * or ojs/ojcontext module not available).
31
+ * This method also checks that the JET UI version matches oraclejet-webdriver
24
32
  * @private
25
33
  * @param driver WebDriver instance
26
34
  * @return A Promise which is resolved to true when the
27
35
  * page's busy state is ready or to false when it is not a JET page.
28
36
  */
29
37
  export const whenBusyContextReady = async (driver: WebDriver): Promise<boolean> => {
30
- return executeWithModules<boolean>(driver, ['BusyContext'], [], (BusyContext) =>
31
- BusyContext.whenReady()
38
+ return executeWithModules<boolean>(
39
+ driver,
40
+ ['BusyContext', 'Core'],
41
+ [{ version: wdPkg.version, revision: wdPkg.config.revision }],
42
+ (BusyContext, Core, { version, revision }: VersionDef) => {
43
+ // inline the version-check to avoid additional timing changes with making another
44
+ // remote script call
45
+ if (
46
+ // Check if not local build (running from JET repo)
47
+ !revision.match(/^#@@oj\.revision@@#$|^local:/) &&
48
+ // or version mismatch
49
+ (version !== Core.version || revision !== Core.revision)
50
+ ) {
51
+ throw Error(
52
+ `version mismatch: oraclejet ${JSON.stringify({
53
+ version: Core.version,
54
+ revision: Core.revision
55
+ })}, oraclejet-webdriver ${JSON.stringify({ version, revision })}`
56
+ );
57
+ }
58
+
59
+ return BusyContext.whenReady();
60
+ }
32
61
  ).catch(async (ex) => {
33
62
  if (ex instanceof error.TimeoutError || ex instanceof error.ScriptTimeoutError) {
34
63
  const openStates = await getBusyStates(driver);
35
64
  throw Error(`BusyContext.whenReady() timed out: ${ex.message}\nBusy states: ${openStates}`);
65
+ } else if (ex.message?.indexOf('version mismatch:') > -1) {
66
+ throw ex;
36
67
  } else {
37
68
  // unexpected error which is just reported as a warning below
38
69
  return false;
@@ -1,350 +1,9 @@
1
- import { Builder, Capabilities, WebDriver } from 'selenium-webdriver';
2
-
3
- interface Timeouts {
4
- /**
5
- * The timeout value for script execution. Default 30000
6
- */
7
- script?: number;
8
- /**
9
- * The timeout value for page loading (and to be ready). Default 30000
10
- */
11
- pageLoad?: number;
12
- /**
13
- * The timeout value for finding an element on the page. Default 0
14
- */
15
- implicit?: number;
16
- }
17
- interface CapabilitiesConfiguration {
18
- /**
19
- * The WebDriver Capabilties for the configuration
20
- */
21
- capabilities?: Capabilities | Map<string, any> | {};
22
- /**
23
- * The WebDriver timeout values for the configuration
24
- */
25
- timeouts?: Timeouts;
26
- }
27
-
28
- /**
29
- * @private
30
- */
31
- const defaultConfigName = '';
32
- /**
33
- * @private
34
- */
35
- const defaultCapabilities = new Capabilities({
36
- autoWebview: true,
37
- browserName: 'chrome'
38
- });
39
- /**
40
- * @private
41
- */
42
- const defaultTimeouts: Timeouts = {
43
- implicit: 0,
44
- pageLoad: 30000,
45
- script: 30000
46
- };
47
- /**
48
- * @private
49
- */
50
- const configs: { [key: string]: CapabilitiesConfiguration } = {};
51
- /**
52
- * @private
53
- */
54
- let currentInstance: { configName: string | undefined; driver: WebDriver | undefined } = {
55
- configName: undefined,
56
- driver: undefined
57
- };
58
-
59
- /**
60
- * The delay, in milliseconds, that the manager will wait after the driver is
61
- * release to see if there are pending requests for a driver instance. If no
62
- * requests exist, then the driver is closed, and subsequent requests will
63
- * receive a new instance.
64
- * @private
65
- */
66
- const quitDelay = 500;
67
- /**
68
- * @private
69
- */
70
- let builder: Builder;
71
- /**
72
- * The NodeJS.Timer used to cleanup the driver instance if no subsequent test
73
- * asks for the driver. The type (NodeJS.Timer) cannot be defined here because
74
- * typedoc cannot resolve the NodeJS namespace, so we infer it by calling
75
- * setTimeout instead.
76
- * @private
77
- */
78
- let releaseTimer = setTimeout(() => true, 0);
79
- /**
80
- * @private
81
- */
82
- let quitPromise = Promise.resolve();
83
-
84
- /**
85
- * Manage instances of [WebDriver](index._internal_.WebDriver.html)
86
- * to be used by the tests. DriverManager
87
- * allows a single place where the WebDriver instance can be configured and
88
- * reused. Traditionally, tests instantiate the WebDriver instance on their own,
89
- * passing configurations such as the browser to use:
90
- * ```javascript
91
- * let driver = new Builder().withCapabilities({
92
- * browserName: "chrome"
93
- * }).build()
94
- * ```
95
- * This boilerplate code then has to be copied to every test. Additionally, if
96
- * the capabilities need to change (say, running against a different browser),
97
- * that change must be applied to all test files.
98
- *
99
- * DriverManager addresses this problem by centralizing the place whereby
100
- * the configuration is done, and persists that configuration for all
101
- * subsequent requests for the WebDriver instance. The configuration only needs
102
- * to be set once in a "setup" file, and tests retrieve the configured instance
103
- * without needing to define anything else.
104
- *
105
- * A sample <code>mocha-setup.ts</code> file which configures DriverManager
106
- * ```javascript
107
- * import { DriverManager } from "@oracle/oraclejet-webdriver";
108
- *
109
- * DriverManager.registerConfig({
110
- * capabilities: new Capabilities({
111
- * browserName: "chrome"
112
- * })
113
- * })
114
- * ```
115
- * This setup test script should be run before any other tests.
116
- * ```bash
117
- * $ node node_modules/mocha/bin/mocha --require=ts-node/register mocha-setup.ts other-test.spec.ts ...
118
- * ```
119
- * Test files are agnostic of the driver configuration, and simply get the instance
120
- * by calling <code>getDriver()</code>
121
- * ```javascript
122
- * import { DriverManager } from "@oracle/oraclejet-webdriver";
123
- *
124
- * describe("My test suite", function() {
125
- * let driver: WebDriver;
126
- *
127
- * before(async function() {
128
- * driver = await DriverManager.getDriver();
129
- * })
130
- * it("open a page to test", async function() {
131
- * await driver.get("...")
132
- * })
133
- * after(async function() {
134
- * await DriverManager.releaseDriver(driver);
135
- * })
136
- * })
137
- * ```
138
- *
139
- * ## Set default timeouts for WebDriver from Mocha.
140
- * When Mocha is used to start the WebDriver tests, there are two sets of timeout
141
- * values--one from Mocha and one from WebDriver. This causes some confusion as
142
- * the command-line argument <code>--timeout=nnn</code> is typically the only one
143
- * set and assumed to be the only timeout value in play. However, WebDriver has
144
- * its own set of timeout values whose defaults are sometimes longer than what's
145
- * set for Mocha. When this happens, WebDriver may be waiting on a condition to
146
- * timeout, but Mocha has errored the test because its own timeout was exceeded.
147
- * To ensure that WebDriver timeout conditions are properly reported to the test
148
- * runner (Mocha), its timeout values must be set to a value shorter than the
149
- * runner's. This is typically done in the setup test, and set to some factor of
150
- * the Mocha timeout.
151
- *
152
- * ### Set WebDriver timeout to 1/4 of Mocha
153
- * ```javascript
154
- * const mochaTimeout = this.timeouts();
155
- * const wdTimeout = mochaTimeout / 4;
156
- * DriverManager.registerConfig({
157
- * timeouts: {
158
- * pageLoad: wdTimeout,
159
- * script: wdTimeout,
160
- * implicit: wdTimeout
161
- * }
162
- * });
163
- * ```
164
- *
165
- */
166
- export class DriverManager {
167
- /**
168
- * Optionally set the {@link Builder}
169
- * instance used by DriverManager to create WebDriver.
170
- * The Builder allows different settings for thigns such as the remote server,
171
- * proxies, and other runtime options often needed when running in distributed
172
- * environments.
173
- * The instance can be preconfigured with capabilities, and any additional
174
- * capabilities from [[registerConfig]] will also be applied during the
175
- * creation process. If no Builder is explicitly passed, a default one will
176
- * be used.
177
- * If setting a custom Builder, this function must be called before the first
178
- * test calls [[getDriver]], and must only be called once per test run. If called
179
- * multiple times or after [[getDriver]], an error will be thrown.
180
- * @param b A builder instance
181
- */
182
- public static setBuilder(b: Builder) {
183
- if (builder) {
184
- throw Error('DriverManager Builder instance has already been set, and cannot be set again');
185
- }
186
- builder = b;
187
- }
188
- /**
189
- * Register a configuration for WebDriver instances. Configurations consist of
190
- * {@link Capabilities} and/or {@link Timeouts}.
191
- * This configuration is used by [[getDriver]] to retrieve a configured WebDriver
192
- * instance.
193
- * @param config The driver configuration
194
- * @param name An optional name to assocaite with the config. If no name is given,
195
- * the config will be the default.
196
- *
197
- * ### Register a default config
198
- * ```javascript
199
- * DriverManager.registerConfig(
200
- * {
201
- * capabilities: new Capabilities({
202
- * browserName: "chrome"
203
- * }),
204
- * timeouts: {
205
- * implicit: 5000
206
- * }
207
- * }
208
- * );
209
- * ```
210
- * ### Register a Firefox config
211
- * ```javascript
212
- * DriverManager.registerConfig(
213
- * {
214
- * capabilities: new Capabilities({
215
- * browserName: "firefox",
216
- * hideAlerts: true
217
- * })
218
- * },
219
- * "firefox-no-alerts"
220
- * );
221
- * ```
222
- */
223
- public static registerConfig(config: CapabilitiesConfiguration, name?: string): void {
224
- configs[name || defaultConfigName] = config;
225
- }
226
-
227
- /**
228
- * Get a {@link WebDriver}
229
- * instance for a given configuration. If no configName is given, the returned
230
- * driver will use the default configuration.
231
- * @see [[registerConfig]]
232
- *
233
- * ### Get driver with default capabilities
234
- * ```javascript
235
- * let driver = await DriverManager.getDriver();
236
- * ```
237
- * ### Configure and get Firefox driver
238
- * ```javascript
239
- * // mocha-setup.ts
240
- * DriverManager.registerConfig(
241
- * {
242
- * browserName: "firefox"
243
- * },
244
- * "firefox-config");
245
- * // test.spec.ts
246
- * let driver = await DriverManager.getDriver("firefox-config");
247
- * ```
248
- * @param configName An optional configuration name, registered through
249
- * [[registerConfig]], whose set will be applied to the driver instance. If no
250
- * name is given, the default configuration with the "chrome" browser
251
- * will be used. If the given configName doesn't exist, an error will be thrown.
252
- * @return A Promise that resolves to a WebDriver instance, configured with
253
- * custom capabilities for the given configName, or the default capabilities
254
- * if none is specified.
255
- */
256
- public static async getDriver(configName?: string): Promise<WebDriver> {
257
- clearTimeout(releaseTimer);
258
- configName = configName || defaultConfigName;
259
-
260
- if (configName === currentInstance.configName) {
261
- // Test if current driver is still valid
262
- try {
263
- if (currentInstance.driver) {
264
- await currentInstance.driver.getCurrentUrl();
265
- return currentInstance.driver;
266
- }
267
- } catch (ex) {}
268
- }
269
-
270
- quitCurrentDriver();
271
- return createDriver(configName);
272
- }
273
-
274
- /**
275
- * Gets the current driver instance, if one exists, otherwise create and
276
- * return the default one. This method is useful for test setups which evaluate
277
- * the outcome of the previous test to capture screenshots on failures. After-
278
- * scripts call <code>getCurrentDriver</code> to get the instance of the driver
279
- * that experienced the test failure, then capture the screenshot from it.
280
- */
281
- public static async getCurrentDriver(): Promise<WebDriver> {
282
- return DriverManager.getDriver(currentInstance.configName);
283
- }
284
-
285
- /**
286
- * Release the WebDriver instance from use. Called when each test is done
287
- * with its driver usage, typicall, in the Mocha <code>after</code> function.
288
- * @param driver The WebDriver instance
289
- */
290
- public static releaseDriver(driver: WebDriver): void {
291
- clearTimeout(releaseTimer);
292
- // Wait for the delay to quit the driver. If [getDriver] was called before
293
- // the timeout expired, then it will have cleared the timeout so that the
294
- // instance isn't closed.
295
- releaseTimer = setTimeout(() => quitDriver(driver), quitDelay);
296
- }
297
- }
298
- DriverManager.registerConfig({ capabilities: defaultCapabilities, timeouts: defaultTimeouts });
299
-
300
- /**
301
- * Create a WebDriver instance from the given configuration name. The config should
302
- * already be registered via [registerConfig].
303
- * @param configName The configuration name used to retrieve the configuration
304
- * object for the driver instance
305
- * @return A Promise which resolves to the configured WebDriver instance
306
- * @private
307
- */
308
- function createDriver(configName: string) {
309
- const config = configs[configName];
310
- if (!config) {
311
- throw Error(`No driver configuration exists for "${configName}"`);
312
- }
313
- // Merge default capabilities with custom ones
314
- const caps = new Capabilities(configs[defaultConfigName].capabilities);
315
- if (config.capabilities) {
316
- caps.merge(config.capabilities);
317
- }
318
- // Merge default timeouts with custom ones
319
- const timeouts = Object.assign({}, configs[defaultConfigName].timeouts, config.timeouts);
320
- if (!builder) {
321
- builder = new Builder();
322
- }
323
-
324
- return quitPromise.then(async () => {
325
- const driver = builder.withCapabilities(caps).build();
326
- currentInstance = { configName, driver };
327
- await driver.manage().setTimeouts(timeouts);
328
- return driver;
329
- });
330
- }
331
-
332
- /**
333
- * @private
334
- */
335
- function quitCurrentDriver() {
336
- quitDriver(currentInstance.driver);
337
- }
338
-
339
- /**
340
- * @private
341
- */
342
- function quitDriver(driver?: WebDriver) {
343
- if (driver) {
344
- currentInstance = {
345
- configName: undefined,
346
- driver: undefined
347
- };
348
- quitPromise = driver.quit().catch((ex) => console.warn(ex));
349
- }
350
- }
1
+ /*
2
+ * Although DriverManager has moved to oraclejet-selenium-driver package, re-export
3
+ * from its original location in case other projects are importing it directly from
4
+ * this folder.
5
+ */
6
+ export {
7
+ DriverManager,
8
+ type DriverConfiguration
9
+ } from '@oracle/oraclejet-selenium-driver/DriverManager';
@@ -86,10 +86,13 @@ WebDriver.prototype.executeAsyncScript = wrapExecuteScript(WebDriver.prototype.e
86
86
  function getWebDriverErrors() {
87
87
  return Object.keys(WebDriverErrors)
88
88
  .filter((c) => c.match(/^[A-Z].+Error$/))
89
- .reduce((accum, className) => {
90
- accum[className] = new WebDriverErrors[className]();
91
- return accum;
92
- }, {});
89
+ .reduce(
90
+ (accum, className) => ({
91
+ ...accum,
92
+ [className]: new WebDriverErrors[className]()
93
+ }),
94
+ {}
95
+ );
93
96
  }
94
97
 
95
98
  /**
package/tsconfig.json CHANGED
@@ -12,11 +12,11 @@
12
12
  "noPropertyAccessFromIndexSignature": true,
13
13
  "noUnusedLocals": true,
14
14
  "noUnusedParameters": true,
15
- "module": "commonjs",
15
+ "module": "Node16",
16
+ "moduleResolution": "node16",
16
17
  "target": "ES2021",
17
18
  "sourceMap": true,
18
19
  "skipLibCheck": true,
19
- "moduleResolution": "node",
20
20
  "types": ["node", "selenium-webdriver"],
21
21
  "paths": {
22
22
  "@oracle/oraclejet/*": ["./node_modules/@oracle/oraclejet/dist/types/*"]