@seleniumhq/code-export-javascript-mocha 3.17.4 → 4.0.0-alpha.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.
@@ -15,11 +15,18 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
- import { codeExport as exporter } from '@seleniumhq/side-code-export'
18
+ import {
19
+ codeExport as exporter,
20
+ ExportFlexCommandShape,
21
+ PrebuildEmitter,
22
+ ProcessedCommandEmitter,
23
+ ScriptShape,
24
+ } from '@seleniumhq/side-code-export'
25
+ import { CommandShape } from '@seleniumhq/side-model'
19
26
  import location from './location'
20
27
  import selection from './selection'
21
28
 
22
- export const emitters = {
29
+ export const emitters: Record<string, ProcessedCommandEmitter> = {
23
30
  addSelection: emitSelect,
24
31
  answerOnNextPrompt: skip,
25
32
  assert: emitAssert,
@@ -114,7 +121,8 @@ export const emitters = {
114
121
  waitForElementNotVisible: emitWaitForElementNotVisible,
115
122
  webdriverAnswerOnVisiblePrompt: emitAnswerOnNextPrompt,
116
123
  waitForText: emitWaitForText,
117
- webdriverChooseCancelOnVisibleConfirmation: emitChooseCancelOnNextConfirmation,
124
+ webdriverChooseCancelOnVisibleConfirmation:
125
+ emitChooseCancelOnNextConfirmation,
118
126
  webdriverChooseCancelOnVisiblePrompt: emitChooseCancelOnNextConfirmation,
119
127
  webdriverChooseOkOnVisibleConfirmation: emitChooseOkOnNextConfirmation,
120
128
  while: emitControlFlowWhile,
@@ -122,31 +130,27 @@ export const emitters = {
122
130
 
123
131
  exporter.register.preprocessors(emitters)
124
132
 
125
- function register(command, emitter) {
133
+ function register(command: string, emitter: PrebuildEmitter) {
126
134
  exporter.register.emitter({ command, emitter, emitters })
127
135
  }
128
136
 
129
- function emit(command) {
137
+ function emit(command: CommandShape) {
130
138
  return exporter.emit.command(command, emitters[command.command], {
131
139
  variableLookup,
132
140
  emitNewWindowHandling,
133
141
  })
134
142
  }
135
143
 
136
- function canEmit(commandName) {
137
- return !!emitters[commandName]
138
- }
139
-
140
- function variableLookup(varName) {
144
+ function variableLookup(varName: string) {
141
145
  return `vars["${varName}"]`
142
146
  }
143
147
 
144
- function variableSetter(varName, value) {
148
+ function variableSetter(varName: string, value: string) {
145
149
  return varName ? `vars["${varName}"] = ${value}` : ''
146
150
  }
147
151
 
148
152
  function emitWaitForWindow() {
149
- const generateMethodDeclaration = name => {
153
+ const generateMethodDeclaration = (name: string) => {
150
154
  return {
151
155
  body: `async function ${name}(timeout = 2) {`,
152
156
  terminatingKeyword: '}',
@@ -178,7 +182,7 @@ function emitWaitForWindow() {
178
182
  })
179
183
  }
180
184
 
181
- async function emitNewWindowHandling(command, emittedCommand) {
185
+ async function emitNewWindowHandling(command: CommandShape, emittedCommand: ExportFlexCommandShape) {
182
186
  return Promise.resolve(
183
187
  `vars["windowHandles"] = await driver.getAllWindowHandles()\n${await emittedCommand}\nvars["${
184
188
  command.windowHandleName
@@ -186,17 +190,17 @@ async function emitNewWindowHandling(command, emittedCommand) {
186
190
  )
187
191
  }
188
192
 
189
- function emitAssert(varName, value) {
193
+ function emitAssert(varName: string, value: string) {
190
194
  return Promise.resolve(`assert(vars["${varName}"].toString() == "${value}")`)
191
195
  }
192
196
 
193
- function emitAssertAlert(alertText) {
197
+ function emitAssertAlert(alertText: string) {
194
198
  return Promise.resolve(
195
199
  `assert(await driver.switchTo().alert().getText() == "${alertText}")`
196
200
  )
197
201
  }
198
202
 
199
- function emitAnswerOnNextPrompt(textToSend) {
203
+ function emitAnswerOnNextPrompt(textToSend: string) {
200
204
  const commands = [
201
205
  { level: 0, statement: `{` },
202
206
  { level: 1, statement: 'const alert = await driver.switchTo().alert()' },
@@ -207,7 +211,7 @@ function emitAnswerOnNextPrompt(textToSend) {
207
211
  return Promise.resolve({ commands })
208
212
  }
209
213
 
210
- async function emitCheck(locator) {
214
+ async function emitCheck(locator: string) {
211
215
  const commands = [
212
216
  {
213
217
  level: 0,
@@ -239,7 +243,7 @@ function emitChooseOkOnNextConfirmation() {
239
243
  return Promise.resolve(`await driver.switchTo().alert().accept()`)
240
244
  }
241
245
 
242
- async function emitClick(target) {
246
+ async function emitClick(target: string) {
243
247
  return Promise.resolve(
244
248
  `await driver.findElement(${await location.emit(target)}).click()`
245
249
  )
@@ -249,15 +253,15 @@ async function emitClose() {
249
253
  return Promise.resolve(`await driver.close()`)
250
254
  }
251
255
 
252
- function generateExpressionScript(script) {
256
+ function generateExpressionScript(script: ScriptShape) {
253
257
  return `await driver.executeScript("return (${
254
258
  script.script
255
259
  })"${generateScriptArguments(script)})`
256
260
  }
257
261
 
258
- function generateScriptArguments(script) {
262
+ function generateScriptArguments(script: ScriptShape) {
259
263
  return `${script.argv.length ? ', ' : ''}${script.argv
260
- .map(varName => `vars["${varName}"]`)
264
+ .map((varName) => `vars["${varName}"]`)
261
265
  .join(',')}`
262
266
  }
263
267
 
@@ -276,7 +280,7 @@ function emitControlFlowElse() {
276
280
  })
277
281
  }
278
282
 
279
- function emitControlFlowElseIf(script) {
283
+ function emitControlFlowElseIf(script: ScriptShape) {
280
284
  return Promise.resolve({
281
285
  commands: [
282
286
  {
@@ -296,7 +300,7 @@ function emitControlFlowEnd() {
296
300
  })
297
301
  }
298
302
 
299
- function emitControlFlowIf(script) {
303
+ function emitControlFlowIf(script: ScriptShape) {
300
304
  return Promise.resolve({
301
305
  commands: [
302
306
  { level: 0, statement: `if (!!${generateExpressionScript(script)}) {` },
@@ -305,7 +309,7 @@ function emitControlFlowIf(script) {
305
309
  })
306
310
  }
307
311
 
308
- function emitControlFlowForEach(collectionVarName, iteratorVarName) {
312
+ function emitControlFlowForEach(collectionVarName: string, iteratorVarName: string) {
309
313
  return Promise.resolve({
310
314
  commands: [
311
315
  {
@@ -324,7 +328,7 @@ function emitControlFlowForEach(collectionVarName, iteratorVarName) {
324
328
  })
325
329
  }
326
330
 
327
- function emitControlFlowRepeatIf(script) {
331
+ function emitControlFlowRepeatIf(script: ScriptShape) {
328
332
  return Promise.resolve({
329
333
  commands: [
330
334
  {
@@ -336,7 +340,7 @@ function emitControlFlowRepeatIf(script) {
336
340
  })
337
341
  }
338
342
 
339
- function emitControlFlowTimes(target) {
343
+ function emitControlFlowTimes(target: string) {
340
344
  const commands = [
341
345
  {
342
346
  level: 0,
@@ -350,7 +354,7 @@ function emitControlFlowTimes(target) {
350
354
  return Promise.resolve({ commands, endingLevelAdjustment: 1 })
351
355
  }
352
356
 
353
- function emitControlFlowWhile(script) {
357
+ function emitControlFlowWhile(script: ScriptShape) {
354
358
  return Promise.resolve({
355
359
  commands: [
356
360
  { level: 0, statement: `while(!!${generateExpressionScript(script)}) {` },
@@ -359,7 +363,7 @@ function emitControlFlowWhile(script) {
359
363
  })
360
364
  }
361
365
 
362
- async function emitDoubleClick(target) {
366
+ async function emitDoubleClick(target: string) {
363
367
  const commands = [
364
368
  { level: 0, statement: `{` },
365
369
  {
@@ -378,7 +382,7 @@ async function emitDoubleClick(target) {
378
382
  return Promise.resolve({ commands })
379
383
  }
380
384
 
381
- async function emitDragAndDrop(dragged, dropped) {
385
+ async function emitDragAndDrop(dragged: string, dropped: string) {
382
386
  const commands = [
383
387
  { level: 0, statement: `{` },
384
388
  {
@@ -403,12 +407,12 @@ async function emitDragAndDrop(dragged, dropped) {
403
407
  return Promise.resolve({ commands })
404
408
  }
405
409
 
406
- async function emitEcho(message) {
410
+ async function emitEcho(message: string) {
407
411
  const _message = message.startsWith('vars[') ? message : `"${message}"`
408
412
  return Promise.resolve(`console.log(${_message})`)
409
413
  }
410
414
 
411
- async function emitEditContent(locator, content) {
415
+ async function emitEditContent(locator: string, content: string) {
412
416
  const commands = [
413
417
  { level: 0, statement: `{` },
414
418
  {
@@ -426,7 +430,7 @@ async function emitEditContent(locator, content) {
426
430
  return Promise.resolve({ commands })
427
431
  }
428
432
 
429
- async function emitExecuteScript(script, varName) {
433
+ async function emitExecuteScript(script: ScriptShape, varName: string) {
430
434
  const scriptString = script.script.replace(/`/g, '\\`')
431
435
  const result = `await driver.executeScript("${scriptString}"${generateScriptArguments(
432
436
  script
@@ -434,14 +438,14 @@ async function emitExecuteScript(script, varName) {
434
438
  return Promise.resolve(variableSetter(varName, result))
435
439
  }
436
440
 
437
- async function emitExecuteAsyncScript(script, varName) {
441
+ async function emitExecuteAsyncScript(script: ScriptShape, varName: string) {
438
442
  const result = `await driver.executeAsyncScript("var callback = arguments[arguments.length - 1];${
439
443
  script.script
440
444
  }.then(callback).catch(callback);${generateScriptArguments(script)}")`
441
445
  return Promise.resolve(variableSetter(varName, result))
442
446
  }
443
447
 
444
- async function emitMouseDown(locator) {
448
+ async function emitMouseDown(locator: string) {
445
449
  const commands = [
446
450
  { level: 0, statement: `{` },
447
451
  {
@@ -460,7 +464,7 @@ async function emitMouseDown(locator) {
460
464
  return Promise.resolve({ commands })
461
465
  }
462
466
 
463
- async function emitMouseMove(locator) {
467
+ async function emitMouseMove(locator: string) {
464
468
  const commands = [
465
469
  { level: 0, statement: `{` },
466
470
  {
@@ -496,7 +500,7 @@ async function emitMouseOut() {
496
500
  return Promise.resolve({ commands })
497
501
  }
498
502
 
499
- async function emitMouseUp(locator) {
503
+ async function emitMouseUp(locator: string) {
500
504
  const commands = [
501
505
  { level: 0, statement: `{` },
502
506
  {
@@ -515,23 +519,24 @@ async function emitMouseUp(locator) {
515
519
  return Promise.resolve({ commands })
516
520
  }
517
521
 
518
- function emitOpen(target) {
522
+ function emitOpen(target: string) {
519
523
  const url = /^(file|http|https):\/\//.test(target)
520
524
  ? `"${target}"`
521
- : `"${global.baseUrl}${target}"`
525
+ : // @ts-expect-error globals yuck
526
+ `"${global.baseUrl}${target}"`
522
527
  return Promise.resolve(`await driver.get(${url})`)
523
528
  }
524
529
 
525
- async function emitPause(time) {
530
+ async function emitPause(time: string) {
526
531
  const commands = [{ level: 0, statement: `await driver.sleep(${time})` }]
527
532
  return Promise.resolve({ commands })
528
533
  }
529
534
 
530
- async function emitRun(testName) {
535
+ async function emitRun(testName: string) {
531
536
  return Promise.resolve(`${exporter.parsers.sanitizeName(testName)}()`)
532
537
  }
533
538
 
534
- async function emitRunScript(script) {
539
+ async function emitRunScript(script: ScriptShape) {
535
540
  return Promise.resolve(
536
541
  `await driver.executeScript("${script.script}${generateScriptArguments(
537
542
  script
@@ -539,14 +544,14 @@ async function emitRunScript(script) {
539
544
  )
540
545
  }
541
546
 
542
- async function emitSetWindowSize(size) {
547
+ async function emitSetWindowSize(size: string) {
543
548
  const [width, height] = size.split('x')
544
549
  return Promise.resolve(
545
550
  `await driver.manage().window().setRect({ width: ${width}, height: ${height} })`
546
551
  )
547
552
  }
548
553
 
549
- async function emitSelect(selectElement, option) {
554
+ async function emitSelect(selectElement: string, option: string) {
550
555
  const commands = [
551
556
  { level: 0, statement: `{` },
552
557
  {
@@ -566,13 +571,13 @@ async function emitSelect(selectElement, option) {
566
571
  return Promise.resolve({ commands })
567
572
  }
568
573
 
569
- async function emitSelectFrame(frameLocation) {
574
+ async function emitSelectFrame(frameLocation: string) {
570
575
  if (frameLocation === 'relative=top' || frameLocation === 'relative=parent') {
571
576
  return Promise.resolve('await driver.switchTo().defaultContent()')
572
577
  } else if (/^index=/.test(frameLocation)) {
573
578
  return Promise.resolve(
574
579
  `await driver.switchTo().frame(${Math.floor(
575
- frameLocation.split('index=')[1]
580
+ Number(frameLocation.split('index=')?.[1])
576
581
  )})`
577
582
  )
578
583
  } else {
@@ -592,7 +597,7 @@ async function emitSelectFrame(frameLocation) {
592
597
  }
593
598
  }
594
599
 
595
- async function emitSelectWindow(windowLocation) {
600
+ async function emitSelectWindow(windowLocation: string) {
596
601
  if (/^handle=/.test(windowLocation)) {
597
602
  return Promise.resolve(
598
603
  `await driver.switchTo().window(${windowLocation.split('handle=')[1]})`
@@ -630,14 +635,14 @@ async function emitSelectWindow(windowLocation) {
630
635
  }
631
636
  }
632
637
 
633
- function generateSendKeysInput(value) {
638
+ function generateSendKeysInput(value: string | string[]) {
634
639
  if (typeof value === 'object') {
635
640
  return value
636
- .map(s => {
641
+ .map((s) => {
637
642
  if (s.startsWith('vars[')) {
638
643
  return s
639
644
  } else if (s.startsWith('Key[')) {
640
- const key = s.match(/\['(.*)'\]/)[1]
645
+ const key = s.match(/\['(.*)'\]/)?.[1]
641
646
  return `Key.${key}`
642
647
  } else {
643
648
  return `"${s}"`
@@ -653,7 +658,7 @@ function generateSendKeysInput(value) {
653
658
  }
654
659
  }
655
660
 
656
- async function emitSendKeys(target, value) {
661
+ async function emitSendKeys(target: string, value: string) {
657
662
  return Promise.resolve(
658
663
  `await driver.findElement(${await location.emit(
659
664
  target
@@ -667,11 +672,11 @@ function emitSetSpeed() {
667
672
  )
668
673
  }
669
674
 
670
- async function emitStore(value, varName) {
675
+ async function emitStore(value: string, varName: string) {
671
676
  return Promise.resolve(variableSetter(varName, `"${value}"`))
672
677
  }
673
678
 
674
- async function emitStoreAttribute(locator, varName) {
679
+ async function emitStoreAttribute(locator: string, varName: string) {
675
680
  const attributePos = locator.lastIndexOf('@')
676
681
  const elementLocator = locator.slice(0, attributePos)
677
682
  const attributeName = locator.slice(attributePos + 1)
@@ -689,48 +694,48 @@ async function emitStoreAttribute(locator, varName) {
689
694
  return Promise.resolve({ commands })
690
695
  }
691
696
 
692
- async function emitStoreJson(json, varName) {
697
+ async function emitStoreJson(json: string, varName: string) {
693
698
  return Promise.resolve(variableSetter(varName, `JSON.parse('${json}')`))
694
699
  }
695
700
 
696
- async function emitStoreText(locator, varName) {
701
+ async function emitStoreText(locator: string, varName: string) {
697
702
  const result = `await driver.findElement(${await location.emit(
698
703
  locator
699
704
  )}).getText()`
700
705
  return Promise.resolve(variableSetter(varName, result))
701
706
  }
702
707
 
703
- async function emitStoreTitle(_, varName) {
708
+ async function emitStoreTitle(_: string, varName: string) {
704
709
  return Promise.resolve(variableSetter(varName, 'await driver.getTitle()'))
705
710
  }
706
711
 
707
- async function emitStoreValue(locator, varName) {
712
+ async function emitStoreValue(locator: string, varName: string) {
708
713
  const result = `await driver.findElement(${await location.emit(
709
714
  locator
710
715
  )}).getAttribute("value")`
711
716
  return Promise.resolve(variableSetter(varName, result))
712
717
  }
713
718
 
714
- async function emitStoreWindowHandle(varName) {
719
+ async function emitStoreWindowHandle(varName: string) {
715
720
  return Promise.resolve(
716
721
  variableSetter(varName, 'await driver.getWindowHandle()')
717
722
  )
718
723
  }
719
724
 
720
- async function emitStoreXpathCount(locator, varName) {
725
+ async function emitStoreXpathCount(locator: string, varName: string) {
721
726
  const result = `await driver.findElements(${await location.emit(
722
727
  locator
723
728
  )}).length`
724
729
  return Promise.resolve(variableSetter(varName, result))
725
730
  }
726
731
 
727
- async function emitSubmit(_locator) {
732
+ async function emitSubmit(_locator: string) {
728
733
  return Promise.resolve(
729
734
  `raise Exception("\`submit\` is not a supported command in Selenium Webdriver. Please re-record the step in the IDE.")`
730
735
  )
731
736
  }
732
737
 
733
- async function emitType(target, value) {
738
+ async function emitType(target: string, value: string) {
734
739
  return Promise.resolve(
735
740
  `await driver.findElement(${await location.emit(
736
741
  target
@@ -738,7 +743,7 @@ async function emitType(target, value) {
738
743
  )
739
744
  }
740
745
 
741
- async function emitUncheck(locator) {
746
+ async function emitUncheck(locator: string) {
742
747
  const commands = [
743
748
  { level: 0, statement: `{` },
744
749
  {
@@ -756,7 +761,7 @@ async function emitUncheck(locator) {
756
761
  return Promise.resolve({ commands })
757
762
  }
758
763
 
759
- async function emitVerifyChecked(locator) {
764
+ async function emitVerifyChecked(locator: string) {
760
765
  return Promise.resolve(
761
766
  `assert(await driver.findElement(${await location.emit(
762
767
  locator
@@ -764,7 +769,7 @@ async function emitVerifyChecked(locator) {
764
769
  )
765
770
  }
766
771
 
767
- async function emitVerifyEditable(locator) {
772
+ async function emitVerifyEditable(locator: string) {
768
773
  const commands = [
769
774
  { level: 0, statement: `{` },
770
775
  {
@@ -779,7 +784,7 @@ async function emitVerifyEditable(locator) {
779
784
  return Promise.resolve({ commands })
780
785
  }
781
786
 
782
- async function emitVerifyElementPresent(locator) {
787
+ async function emitVerifyElementPresent(locator: string) {
783
788
  const commands = [
784
789
  { level: 0, statement: `{` },
785
790
  {
@@ -794,7 +799,7 @@ async function emitVerifyElementPresent(locator) {
794
799
  return Promise.resolve({ commands })
795
800
  }
796
801
 
797
- async function emitVerifyElementNotPresent(locator) {
802
+ async function emitVerifyElementNotPresent(locator: string) {
798
803
  const commands = [
799
804
  { level: 0, statement: `{` },
800
805
  {
@@ -809,7 +814,7 @@ async function emitVerifyElementNotPresent(locator) {
809
814
  return Promise.resolve({ commands })
810
815
  }
811
816
 
812
- async function emitVerifyNotChecked(locator) {
817
+ async function emitVerifyNotChecked(locator: string) {
813
818
  return Promise.resolve(
814
819
  `assert(!await driver.findElement(${await location.emit(
815
820
  locator
@@ -817,7 +822,7 @@ async function emitVerifyNotChecked(locator) {
817
822
  )
818
823
  }
819
824
 
820
- async function emitVerifyNotEditable(locator) {
825
+ async function emitVerifyNotEditable(locator: string) {
821
826
  const commands = [
822
827
  { level: 0, statement: `{` },
823
828
  {
@@ -832,7 +837,7 @@ async function emitVerifyNotEditable(locator) {
832
837
  return Promise.resolve({ commands })
833
838
  }
834
839
 
835
- async function emitVerifyNotSelectedValue(locator, expectedValue) {
840
+ async function emitVerifyNotSelectedValue(locator: string, expectedValue: string) {
836
841
  const commands = [
837
842
  { level: 0, statement: `{` },
838
843
  {
@@ -850,7 +855,7 @@ async function emitVerifyNotSelectedValue(locator, expectedValue) {
850
855
  return Promise.resolve({ commands })
851
856
  }
852
857
 
853
- async function emitVerifyNotText(locator, text) {
858
+ async function emitVerifyNotText(locator: string, text: string) {
854
859
  const commands = [
855
860
  { level: 0, statement: `{` },
856
861
  {
@@ -865,7 +870,7 @@ async function emitVerifyNotText(locator, text) {
865
870
  return Promise.resolve({ commands })
866
871
  }
867
872
 
868
- async function emitVerifySelectedLabel(locator, labelValue) {
873
+ async function emitVerifySelectedLabel(locator: string, labelValue: string) {
869
874
  const commands = [
870
875
  { level: 0, statement: `{` },
871
876
  {
@@ -892,7 +897,7 @@ async function emitVerifySelectedLabel(locator, labelValue) {
892
897
  })
893
898
  }
894
899
 
895
- async function emitVerifyText(locator, text) {
900
+ async function emitVerifyText(locator: string, text: string) {
896
901
  const commands = [
897
902
  {
898
903
  level: 0,
@@ -904,7 +909,7 @@ async function emitVerifyText(locator, text) {
904
909
  return Promise.resolve({ commands })
905
910
  }
906
911
 
907
- async function emitVerifyValue(locator, value) {
912
+ async function emitVerifyValue(locator: string, value: string) {
908
913
  const commands = [
909
914
  { level: 0, statement: `{` },
910
915
  {
@@ -919,15 +924,15 @@ async function emitVerifyValue(locator, value) {
919
924
  return Promise.resolve({ commands })
920
925
  }
921
926
 
922
- async function emitVerifyTitle(title) {
927
+ async function emitVerifyTitle(title: string) {
923
928
  return Promise.resolve(`assert(await driver.getTitle() == "${title}")`)
924
929
  }
925
930
 
926
931
  function skip() {
927
- return Promise.resolve(undefined)
932
+ return Promise.resolve('')
928
933
  }
929
934
 
930
- async function emitWaitForElementPresent(locator, timeout) {
935
+ async function emitWaitForElementPresent(locator: string, timeout: number) {
931
936
  return Promise.resolve(
932
937
  `await driver.wait(until.elementLocated(${await location.emit(
933
938
  locator
@@ -935,7 +940,7 @@ async function emitWaitForElementPresent(locator, timeout) {
935
940
  )
936
941
  }
937
942
 
938
- async function emitWaitForElementNotPresent(locator, timeout) {
943
+ async function emitWaitForElementNotPresent(locator: string, timeout: number) {
939
944
  return Promise.resolve(
940
945
  `await driver.wait(until.stalenessOf(await driver.findElement(${await location.emit(
941
946
  locator
@@ -943,7 +948,7 @@ async function emitWaitForElementNotPresent(locator, timeout) {
943
948
  )
944
949
  }
945
950
 
946
- async function emitWaitForElementVisible(locator, timeout) {
951
+ async function emitWaitForElementVisible(locator: string, timeout: number) {
947
952
  return Promise.resolve(
948
953
  `await driver.wait(until.elementIsVisible(await driver.findElement(${await location.emit(
949
954
  locator
@@ -951,7 +956,7 @@ async function emitWaitForElementVisible(locator, timeout) {
951
956
  )
952
957
  }
953
958
 
954
- async function emitWaitForElementNotVisible(locator, timeout) {
959
+ async function emitWaitForElementNotVisible(locator: string, timeout: number) {
955
960
  return Promise.resolve(
956
961
  `await driver.wait(until.elementIsNotVisible(await driver.findElement(${await location.emit(
957
962
  locator
@@ -959,7 +964,7 @@ async function emitWaitForElementNotVisible(locator, timeout) {
959
964
  )
960
965
  }
961
966
 
962
- async function emitWaitForElementEditable(locator, timeout) {
967
+ async function emitWaitForElementEditable(locator: string, timeout: number) {
963
968
  return Promise.resolve(
964
969
  `await driver.wait(until.elementIsEnabled(await driver.findElement(${await location.emit(
965
970
  locator
@@ -967,7 +972,7 @@ async function emitWaitForElementEditable(locator, timeout) {
967
972
  )
968
973
  }
969
974
 
970
- async function emitWaitForElementNotEditable(locator, timeout) {
975
+ async function emitWaitForElementNotEditable(locator: string, timeout: number) {
971
976
  return Promise.resolve(
972
977
  `await driver.wait(until.elementIsDisabled(await driver.findElement(${await location.emit(
973
978
  locator
@@ -975,7 +980,7 @@ async function emitWaitForElementNotEditable(locator, timeout) {
975
980
  )
976
981
  }
977
982
 
978
- async function emitWaitForText(locator, text) {
983
+ async function emitWaitForText(locator: string, text: string) {
979
984
  const timeout = 30000
980
985
  return Promise.resolve(
981
986
  `await driver.wait(until.elementTextIs(await driver.findElement(${await location.emit(
@@ -985,8 +990,8 @@ async function emitWaitForText(locator, text) {
985
990
  }
986
991
 
987
992
  export default {
988
- canEmit,
989
993
  emit,
994
+ emitters,
995
+ extras: { emitNewWindowHandling, emitWaitForWindow },
990
996
  register,
991
- extras: { emitWaitForWindow },
992
997
  }
@@ -14,7 +14,7 @@
14
14
  // KIND, either express or implied. See the License for the specific language governing permissions and limitations
15
15
  // under the License.
16
16
 
17
- import { codeExport as exporter } from '@seleniumhq/side-code-export'
17
+ import { HookFunctionInputs } from "@seleniumhq/side-code-export"
18
18
 
19
19
  const emitters = {
20
20
  afterAll,
@@ -28,17 +28,7 @@ const emitters = {
28
28
  inEachEnd: empty,
29
29
  }
30
30
 
31
- function generate(hookName) {
32
- return new exporter.hook(emitters[hookName]())
33
- }
34
-
35
- export function generateHooks() {
36
- let result = {}
37
- Object.keys(emitters).forEach(hookName => {
38
- result[hookName] = generate(hookName)
39
- })
40
- return result
41
- }
31
+ export default emitters
42
32
 
43
33
  function afterAll() {
44
34
  const params = {
@@ -82,7 +72,7 @@ function beforeAll() {
82
72
  }
83
73
 
84
74
  function beforeEach() {
85
- const params = {
75
+ const params: HookFunctionInputs = {
86
76
  startingSyntax: ({ browserName, gridUrl } = {}) => ({
87
77
  commands: [
88
78
  { level: 0, statement: 'beforeEach(async function() {' },