@seleniumhq/code-export-python-pytest 3.17.2 → 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-utils'
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 `self.vars["${varName}"]`
142
146
  }
143
147
 
144
- function variableSetter(varName, value) {
148
+ function variableSetter(varName: string, value: string) {
145
149
  return varName ? `self.vars["${varName}"] = ${value}` : ''
146
150
  }
147
151
 
148
152
  function emitWaitForWindow() {
149
- const generateMethodDeclaration = name => {
153
+ const generateMethodDeclaration = (name: string) => {
150
154
  return `def ${name}(self, timeout = 2):`
151
155
  }
152
156
  const commands = [
@@ -169,7 +173,10 @@ function emitWaitForWindow() {
169
173
  })
170
174
  }
171
175
 
172
- async function emitNewWindowHandling(command, emittedCommand) {
176
+ async function emitNewWindowHandling(
177
+ command: CommandShape,
178
+ emittedCommand: ExportFlexCommandShape
179
+ ) {
173
180
  return Promise.resolve(
174
181
  `self.vars["window_handles"] = self.driver.window_handles\n${await emittedCommand}\nself.vars["${
175
182
  command.windowHandleName
@@ -177,7 +184,7 @@ async function emitNewWindowHandling(command, emittedCommand) {
177
184
  )
178
185
  }
179
186
 
180
- function emitAssert(varName, value) {
187
+ function emitAssert(varName: string, value: string) {
181
188
  let _value
182
189
  if (value === 'true' || value === 'false') {
183
190
  _value = exporter.parsers.capitalize(value)
@@ -190,13 +197,13 @@ function emitAssert(varName, value) {
190
197
  return Promise.resolve(result)
191
198
  }
192
199
 
193
- function emitAssertAlert(alertText) {
200
+ function emitAssertAlert(alertText: string) {
194
201
  return Promise.resolve(
195
202
  `assert self.driver.switch_to.alert.text == "${alertText}"`
196
203
  )
197
204
  }
198
205
 
199
- function emitAnswerOnNextPrompt(textToSend) {
206
+ function emitAnswerOnNextPrompt(textToSend: string) {
200
207
  const commands = [
201
208
  { level: 0, statement: 'alert = self.driver.switch_to.alert' },
202
209
  { level: 0, statement: `alert.send_keys("${textToSend}")` },
@@ -205,7 +212,7 @@ function emitAnswerOnNextPrompt(textToSend) {
205
212
  return Promise.resolve({ commands })
206
213
  }
207
214
 
208
- async function emitCheck(locator) {
215
+ async function emitCheck(locator: string) {
209
216
  const commands = [
210
217
  {
211
218
  level: 0,
@@ -229,7 +236,7 @@ function emitChooseOkOnNextConfirmation() {
229
236
  return Promise.resolve(`self.driver.switch_to.alert.accept()`)
230
237
  }
231
238
 
232
- async function emitClick(target) {
239
+ async function emitClick(target: string) {
233
240
  return Promise.resolve(
234
241
  `self.driver.find_element(${await location.emit(target)}).click()`
235
242
  )
@@ -239,15 +246,15 @@ async function emitClose() {
239
246
  return Promise.resolve(`self.driver.close()`)
240
247
  }
241
248
 
242
- function generateExpressionScript(script) {
249
+ function generateExpressionScript(script: ScriptShape) {
243
250
  return `self.driver.execute_script("return (${
244
251
  script.script
245
252
  })"${generateScriptArguments(script)})`
246
253
  }
247
254
 
248
- function generateScriptArguments(script) {
255
+ function generateScriptArguments(script: ScriptShape) {
249
256
  return `${script.argv.length ? ', ' : ''}${script.argv
250
- .map(varName => `self.vars["${varName}"]`)
257
+ .map((varName) => `self.vars["${varName}"]`)
251
258
  .join(',')}`
252
259
  }
253
260
 
@@ -269,7 +276,7 @@ function emitControlFlowElse() {
269
276
  })
270
277
  }
271
278
 
272
- function emitControlFlowElseIf(script) {
279
+ function emitControlFlowElseIf(script: ScriptShape) {
273
280
  return Promise.resolve({
274
281
  commands: [
275
282
  {
@@ -290,7 +297,7 @@ function emitControlFlowEnd() {
290
297
  })
291
298
  }
292
299
 
293
- function emitControlFlowIf(script) {
300
+ function emitControlFlowIf(script: ScriptShape) {
294
301
  return Promise.resolve({
295
302
  commands: [
296
303
  { level: 0, statement: `if ${generateExpressionScript(script)}:` },
@@ -299,7 +306,10 @@ function emitControlFlowIf(script) {
299
306
  })
300
307
  }
301
308
 
302
- function emitControlFlowForEach(collectionVarName, iteratorVarName) {
309
+ function emitControlFlowForEach(
310
+ collectionVarName: string,
311
+ iteratorVarName: string
312
+ ) {
303
313
  return Promise.resolve({
304
314
  commands: [
305
315
  {
@@ -318,7 +328,7 @@ function emitControlFlowForEach(collectionVarName, iteratorVarName) {
318
328
  })
319
329
  }
320
330
 
321
- function emitControlFlowRepeatIf(script) {
331
+ function emitControlFlowRepeatIf(script: ScriptShape) {
322
332
  return Promise.resolve({
323
333
  commands: [
324
334
  {
@@ -330,12 +340,12 @@ function emitControlFlowRepeatIf(script) {
330
340
  })
331
341
  }
332
342
 
333
- function emitControlFlowTimes(target) {
343
+ function emitControlFlowTimes(target: string) {
334
344
  const commands = [{ level: 0, statement: `for i in range(0, ${target}):` }]
335
345
  return Promise.resolve({ commands, endingLevelAdjustment: 1 })
336
346
  }
337
347
 
338
- function emitControlFlowWhile(script) {
348
+ function emitControlFlowWhile(script: ScriptShape) {
339
349
  return Promise.resolve({
340
350
  commands: [
341
351
  { level: 0, statement: `while ${generateExpressionScript(script)}:` },
@@ -344,7 +354,7 @@ function emitControlFlowWhile(script) {
344
354
  })
345
355
  }
346
356
 
347
- async function emitDoubleClick(target) {
357
+ async function emitDoubleClick(target: string) {
348
358
  const commands = [
349
359
  {
350
360
  level: 0,
@@ -358,7 +368,7 @@ async function emitDoubleClick(target) {
358
368
  return Promise.resolve({ commands })
359
369
  }
360
370
 
361
- async function emitDragAndDrop(dragged, dropped) {
371
+ async function emitDragAndDrop(dragged: string, dropped: string) {
362
372
  const commands = [
363
373
  {
364
374
  level: 0,
@@ -381,7 +391,7 @@ async function emitDragAndDrop(dragged, dropped) {
381
391
  return Promise.resolve({ commands })
382
392
  }
383
393
 
384
- function translateToPythonString(str) {
394
+ function translateToPythonString(str: string) {
385
395
  const regExp = /self.vars\["\w+"]/
386
396
  const vars = str.match(regExp)
387
397
 
@@ -393,12 +403,12 @@ function translateToPythonString(str) {
393
403
  return `"${str}"`
394
404
  }
395
405
 
396
- async function emitEcho(message) {
406
+ async function emitEcho(message: string) {
397
407
  const _message = translateToPythonString(message)
398
408
  return Promise.resolve(`print(${_message})`)
399
409
  }
400
410
 
401
- async function emitEditContent(locator, content) {
411
+ async function emitEditContent(locator: string, content: string) {
402
412
  const commands = [
403
413
  {
404
414
  level: 0,
@@ -414,7 +424,7 @@ async function emitEditContent(locator, content) {
414
424
  return Promise.resolve({ commands })
415
425
  }
416
426
 
417
- async function emitExecuteScript(script, varName) {
427
+ async function emitExecuteScript(script: ScriptShape, varName: string) {
418
428
  const scriptString = script.script.replace(/"/g, "'")
419
429
  const result = `self.driver.execute_script("${scriptString}"${generateScriptArguments(
420
430
  script
@@ -422,14 +432,14 @@ async function emitExecuteScript(script, varName) {
422
432
  return Promise.resolve(variableSetter(varName, result))
423
433
  }
424
434
 
425
- async function emitExecuteAsyncScript(script, varName) {
435
+ async function emitExecuteAsyncScript(script: ScriptShape, varName: string) {
426
436
  const result = `self.driver.execute_async_script("var callback = arguments[arguments.length - 1];${
427
437
  script.script
428
438
  }.then(callback).catch(callback);${generateScriptArguments(script)}")`
429
439
  return Promise.resolve(variableSetter(varName, result))
430
440
  }
431
441
 
432
- async function emitMouseDown(locator) {
442
+ async function emitMouseDown(locator: string) {
433
443
  const commands = [
434
444
  {
435
445
  level: 0,
@@ -446,7 +456,7 @@ async function emitMouseDown(locator) {
446
456
  return Promise.resolve({ commands })
447
457
  }
448
458
 
449
- async function emitMouseMove(locator) {
459
+ async function emitMouseMove(locator: string) {
450
460
  const commands = [
451
461
  {
452
462
  level: 0,
@@ -472,7 +482,7 @@ async function emitMouseOut() {
472
482
  return Promise.resolve({ commands })
473
483
  }
474
484
 
475
- async function emitMouseUp(locator) {
485
+ async function emitMouseUp(locator: string) {
476
486
  const commands = [
477
487
  {
478
488
  level: 0,
@@ -489,24 +499,25 @@ async function emitMouseUp(locator) {
489
499
  return Promise.resolve({ commands })
490
500
  }
491
501
 
492
- function emitOpen(target) {
502
+ function emitOpen(target: string) {
493
503
  const url = /^(file|http|https):\/\//.test(target)
494
504
  ? `"${target}"`
495
- : `"${global.baseUrl}${target}"`
505
+ : // @ts-expect-error globals yuck
506
+ `"${global.baseUrl}${target}"`
496
507
  return Promise.resolve(`self.driver.get(${url})`)
497
508
  }
498
509
 
499
- async function emitPause(time) {
510
+ async function emitPause(time: number) {
500
511
  const sec = time / 1000
501
512
  const commands = [{ level: 0, statement: `time.sleep(${sec})` }]
502
513
  return Promise.resolve({ commands })
503
514
  }
504
515
 
505
- async function emitRun(testName) {
516
+ async function emitRun(testName: string) {
506
517
  return Promise.resolve(`self.${exporter.parsers.sanitizeName(testName)}()`)
507
518
  }
508
519
 
509
- async function emitRunScript(script) {
520
+ async function emitRunScript(script: ScriptShape) {
510
521
  return Promise.resolve(
511
522
  `self.driver.execute_script("${script.script}${generateScriptArguments(
512
523
  script
@@ -514,12 +525,12 @@ async function emitRunScript(script) {
514
525
  )
515
526
  }
516
527
 
517
- async function emitSetWindowSize(size) {
528
+ async function emitSetWindowSize(size: string) {
518
529
  const [width, height] = size.split('x')
519
530
  return Promise.resolve(`self.driver.set_window_size(${width}, ${height})`)
520
531
  }
521
532
 
522
- async function emitSelect(selectElement, option) {
533
+ async function emitSelect(selectElement: string, option: string) {
523
534
  const commands = [
524
535
  {
525
536
  level: 0,
@@ -537,13 +548,13 @@ async function emitSelect(selectElement, option) {
537
548
  return Promise.resolve({ commands })
538
549
  }
539
550
 
540
- async function emitSelectFrame(frameLocation) {
551
+ async function emitSelectFrame(frameLocation: string) {
541
552
  if (frameLocation === 'relative=top' || frameLocation === 'relative=parent') {
542
553
  return Promise.resolve('self.driver.switch_to.default_content()')
543
554
  } else if (/^index=/.test(frameLocation)) {
544
555
  return Promise.resolve(
545
556
  `self.driver.switch_to.frame(${Math.floor(
546
- frameLocation.split('index=')[1]
557
+ Number(frameLocation.split('index=')?.[1])
547
558
  )})`
548
559
  )
549
560
  } else {
@@ -561,7 +572,7 @@ async function emitSelectFrame(frameLocation) {
561
572
  }
562
573
  }
563
574
 
564
- async function emitSelectWindow(windowLocation) {
575
+ async function emitSelectWindow(windowLocation: string) {
565
576
  if (/^handle=/.test(windowLocation)) {
566
577
  return Promise.resolve(
567
578
  `self.driver.switch_to.window(${windowLocation.split('handle=')[1]})`
@@ -599,14 +610,14 @@ async function emitSelectWindow(windowLocation) {
599
610
  }
600
611
  }
601
612
 
602
- function generateSendKeysInput(value) {
613
+ function generateSendKeysInput(value: string | string[]) {
603
614
  if (typeof value === 'object') {
604
615
  return value
605
- .map(s => {
616
+ .map((s) => {
606
617
  if (s.startsWith('self.vars[')) {
607
618
  return s
608
619
  } else if (s.startsWith('Key[')) {
609
- const key = s.match(/\['(.*)'\]/)[1]
620
+ const key = s.match(/\['(.*)'\]/)?.[1]
610
621
  return `Keys.${key}`
611
622
  } else {
612
623
  return `"${s}"`
@@ -622,7 +633,7 @@ function generateSendKeysInput(value) {
622
633
  }
623
634
  }
624
635
 
625
- async function emitSendKeys(target, value) {
636
+ async function emitSendKeys(target: string, value: string) {
626
637
  return Promise.resolve(
627
638
  `self.driver.find_element(${await location.emit(
628
639
  target
@@ -636,11 +647,11 @@ function emitSetSpeed() {
636
647
  )
637
648
  }
638
649
 
639
- async function emitStore(value, varName) {
650
+ async function emitStore(value: string, varName: string) {
640
651
  return Promise.resolve(variableSetter(varName, `"${value}"`))
641
652
  }
642
653
 
643
- async function emitStoreAttribute(locator, varName) {
654
+ async function emitStoreAttribute(locator: string, varName: string) {
644
655
  const attributePos = locator.lastIndexOf('@')
645
656
  const elementLocator = locator.slice(0, attributePos)
646
657
  const attributeName = locator.slice(attributePos + 1)
@@ -656,48 +667,48 @@ async function emitStoreAttribute(locator, varName) {
656
667
  return Promise.resolve({ commands })
657
668
  }
658
669
 
659
- async function emitStoreJson(json, varName) {
670
+ async function emitStoreJson(json: string, varName: string) {
660
671
  return Promise.resolve(variableSetter(varName, `json.loads('${json}')`))
661
672
  }
662
673
 
663
- async function emitStoreText(locator, varName) {
674
+ async function emitStoreText(locator: string, varName: string) {
664
675
  const result = `self.driver.find_element(${await location.emit(
665
676
  locator
666
677
  )}).text`
667
678
  return Promise.resolve(variableSetter(varName, result))
668
679
  }
669
680
 
670
- async function emitStoreTitle(_, varName) {
681
+ async function emitStoreTitle(_: string, varName: string) {
671
682
  return Promise.resolve(variableSetter(varName, 'self.driver.title'))
672
683
  }
673
684
 
674
- async function emitStoreValue(locator, varName) {
685
+ async function emitStoreValue(locator: string, varName: string) {
675
686
  const result = `self.driver.find_element(${await location.emit(
676
687
  locator
677
688
  )}).get_attribute("value")`
678
689
  return Promise.resolve(variableSetter(varName, result))
679
690
  }
680
691
 
681
- async function emitStoreWindowHandle(varName) {
692
+ async function emitStoreWindowHandle(varName: string) {
682
693
  return Promise.resolve(
683
694
  variableSetter(varName, 'self.driver.current_window_handle')
684
695
  )
685
696
  }
686
697
 
687
- async function emitStoreXpathCount(locator, varName) {
698
+ async function emitStoreXpathCount(locator: string, varName: string) {
688
699
  const result = `len(self.driver.find_elements(${await location.emit(
689
700
  locator
690
701
  )}))`
691
702
  return Promise.resolve(variableSetter(varName, result))
692
703
  }
693
704
 
694
- async function emitSubmit(_locator) {
705
+ async function emitSubmit(_locator: string) {
695
706
  return Promise.resolve(
696
707
  `raise Exception("'submit' is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.")`
697
708
  )
698
709
  }
699
710
 
700
- async function emitType(target, value) {
711
+ async function emitType(target: string, value: string) {
701
712
  return Promise.resolve(
702
713
  `self.driver.find_element(${await location.emit(
703
714
  target
@@ -705,7 +716,7 @@ async function emitType(target, value) {
705
716
  )
706
717
  }
707
718
 
708
- async function emitUncheck(locator) {
719
+ async function emitUncheck(locator: string) {
709
720
  const commands = [
710
721
  {
711
722
  level: 0,
@@ -718,7 +729,7 @@ async function emitUncheck(locator) {
718
729
  return Promise.resolve({ commands })
719
730
  }
720
731
 
721
- async function emitVerifyChecked(locator) {
732
+ async function emitVerifyChecked(locator: string) {
722
733
  return Promise.resolve(
723
734
  `assert self.driver.find_element(${await location.emit(
724
735
  locator
@@ -726,7 +737,7 @@ async function emitVerifyChecked(locator) {
726
737
  )
727
738
  }
728
739
 
729
- async function emitVerifyEditable(locator) {
740
+ async function emitVerifyEditable(locator: string) {
730
741
  const commands = [
731
742
  {
732
743
  level: 0,
@@ -739,7 +750,7 @@ async function emitVerifyEditable(locator) {
739
750
  return Promise.resolve({ commands })
740
751
  }
741
752
 
742
- async function emitVerifyElementPresent(locator) {
753
+ async function emitVerifyElementPresent(locator: string) {
743
754
  const commands = [
744
755
  {
745
756
  level: 0,
@@ -752,7 +763,7 @@ async function emitVerifyElementPresent(locator) {
752
763
  return Promise.resolve({ commands })
753
764
  }
754
765
 
755
- async function emitVerifyElementNotPresent(locator) {
766
+ async function emitVerifyElementNotPresent(locator: string) {
756
767
  const commands = [
757
768
  {
758
769
  level: 0,
@@ -765,7 +776,7 @@ async function emitVerifyElementNotPresent(locator) {
765
776
  return Promise.resolve({ commands })
766
777
  }
767
778
 
768
- async function emitVerifyNotChecked(locator) {
779
+ async function emitVerifyNotChecked(locator: string) {
769
780
  return Promise.resolve(
770
781
  `assert self.driver.find_element(${await location.emit(
771
782
  locator
@@ -773,7 +784,7 @@ async function emitVerifyNotChecked(locator) {
773
784
  )
774
785
  }
775
786
 
776
- async function emitVerifyNotEditable(locator) {
787
+ async function emitVerifyNotEditable(locator: string) {
777
788
  const commands = [
778
789
  {
779
790
  level: 0,
@@ -786,7 +797,10 @@ async function emitVerifyNotEditable(locator) {
786
797
  return Promise.resolve({ commands })
787
798
  }
788
799
 
789
- async function emitVerifyNotSelectedValue(locator, expectedValue) {
800
+ async function emitVerifyNotSelectedValue(
801
+ locator: string,
802
+ expectedValue: string
803
+ ) {
790
804
  const commands = [
791
805
  {
792
806
  level: 0,
@@ -802,7 +816,7 @@ async function emitVerifyNotSelectedValue(locator, expectedValue) {
802
816
  return Promise.resolve({ commands })
803
817
  }
804
818
 
805
- async function emitVerifyNotText(locator, text) {
819
+ async function emitVerifyNotText(locator: string, text: string) {
806
820
  const commands = [
807
821
  {
808
822
  level: 0,
@@ -815,7 +829,7 @@ async function emitVerifyNotText(locator, text) {
815
829
  return Promise.resolve({ commands })
816
830
  }
817
831
 
818
- async function emitVerifySelectedLabel(locator, labelValue) {
832
+ async function emitVerifySelectedLabel(locator: string, labelValue: string) {
819
833
  const commands = [
820
834
  {
821
835
  level: 0,
@@ -838,7 +852,7 @@ async function emitVerifySelectedLabel(locator, labelValue) {
838
852
  })
839
853
  }
840
854
 
841
- async function emitVerifyText(locator, text) {
855
+ async function emitVerifyText(locator: string, text: string) {
842
856
  const commands = [
843
857
  {
844
858
  level: 0,
@@ -850,7 +864,7 @@ async function emitVerifyText(locator, text) {
850
864
  return Promise.resolve({ commands })
851
865
  }
852
866
 
853
- async function emitVerifyValue(locator, value) {
867
+ async function emitVerifyValue(locator: string, value: string) {
854
868
  const commands = [
855
869
  {
856
870
  level: 0,
@@ -863,11 +877,11 @@ async function emitVerifyValue(locator, value) {
863
877
  return Promise.resolve({ commands })
864
878
  }
865
879
 
866
- async function emitVerifyTitle(title) {
880
+ async function emitVerifyTitle(title: string) {
867
881
  return Promise.resolve(`assert self.driver.title == "${title}"`)
868
882
  }
869
883
 
870
- async function emitWaitForElementEditable(locator, timeout) {
884
+ async function emitWaitForElementEditable(locator: string, timeout: number) {
871
885
  const sec = timeout / 1000
872
886
  const commands = [
873
887
  {
@@ -880,7 +894,7 @@ async function emitWaitForElementEditable(locator, timeout) {
880
894
  return Promise.resolve({ commands })
881
895
  }
882
896
 
883
- async function emitWaitForText(locator, text) {
897
+ async function emitWaitForText(locator: string, text: string) {
884
898
  const timeout = 30000
885
899
  const sec = timeout / 1000
886
900
  const commands = [
@@ -895,10 +909,10 @@ async function emitWaitForText(locator, text) {
895
909
  }
896
910
 
897
911
  function skip() {
898
- return Promise.resolve(undefined)
912
+ return Promise.resolve('')
899
913
  }
900
914
 
901
- async function emitWaitForElementPresent(locator, timeout) {
915
+ async function emitWaitForElementPresent(locator: string, timeout: number) {
902
916
  const sec = timeout / 1000
903
917
  const commands = [
904
918
  {
@@ -911,7 +925,7 @@ async function emitWaitForElementPresent(locator, timeout) {
911
925
  return Promise.resolve({ commands })
912
926
  }
913
927
 
914
- async function emitWaitForElementVisible(locator, timeout) {
928
+ async function emitWaitForElementVisible(locator: string, timeout: number) {
915
929
  const sec = timeout / 1000
916
930
  const commands = [
917
931
  {
@@ -926,7 +940,7 @@ async function emitWaitForElementVisible(locator, timeout) {
926
940
  })
927
941
  }
928
942
 
929
- async function emitWaitForElementNotEditable(locator, timeout) {
943
+ async function emitWaitForElementNotEditable(locator: string, timeout: number) {
930
944
  const sec = timeout / 1000
931
945
  const commands = [
932
946
  {
@@ -941,7 +955,7 @@ async function emitWaitForElementNotEditable(locator, timeout) {
941
955
  })
942
956
  }
943
957
 
944
- async function emitWaitForElementNotPresent(locator, timeout) {
958
+ async function emitWaitForElementNotPresent(locator: string, timeout: number) {
945
959
  const sec = timeout / 1000
946
960
  const commands = [
947
961
  {
@@ -956,7 +970,7 @@ async function emitWaitForElementNotPresent(locator, timeout) {
956
970
  })
957
971
  }
958
972
 
959
- async function emitWaitForElementNotVisible(locator, timeout) {
973
+ async function emitWaitForElementNotVisible(locator: string, timeout: number) {
960
974
  const sec = timeout / 1000
961
975
  const commands = [
962
976
  {
@@ -972,8 +986,8 @@ async function emitWaitForElementNotVisible(locator, timeout) {
972
986
  }
973
987
 
974
988
  export default {
975
- canEmit,
976
989
  emit,
990
+ emitters,
977
991
  register,
978
- extras: { emitWaitForWindow },
992
+ extras: { emitNewWindowHandling, emitWaitForWindow },
979
993
  }
@@ -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-utils'
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: 'def setup_method(self, method):' },