@seleniumhq/code-export-csharp-commons 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,14 @@
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 { codeExport as exporter, PrebuildEmitter } from '@seleniumhq/side-code-export'
19
+ import { ExportFlexCommandShape, ProcessedCommandEmitter } from '@seleniumhq/side-code-export/dist/code-export/emit'
20
+ import { ScriptShape } from '@seleniumhq/side-code-export/src/code-export/preprocessor'
21
+ import { CommandShape } from '@seleniumhq/side-model'
19
22
  import location from './location'
20
23
  import selection from './selection'
21
24
 
22
- export const emitters = {
25
+ export const emitters: Record<string, ProcessedCommandEmitter> = {
23
26
  addSelection: emitSelect,
24
27
  answerOnNextPrompt: skip,
25
28
  assert: emitAssert,
@@ -114,7 +117,8 @@ export const emitters = {
114
117
  waitForElementNotVisible: emitWaitForElementNotVisible,
115
118
  waitForText: emitWaitForText,
116
119
  webDriverAnswerOnVisiblePrompt: emitAnswerOnNextPrompt,
117
- webDriverChooseCancelOnVisibleConfirmation: emitChooseCancelOnNextConfirmation,
120
+ webDriverChooseCancelOnVisibleConfirmation:
121
+ emitChooseCancelOnNextConfirmation,
118
122
  webDriverChooseCancelOnVisiblePrompt: emitChooseCancelOnNextConfirmation,
119
123
  webDriverChooseOkOnVisibleConfirmation: emitChooseOkOnNextConfirmation,
120
124
  while: emitControlFlowWhile,
@@ -122,31 +126,27 @@ export const emitters = {
122
126
 
123
127
  exporter.register.preprocessors(emitters)
124
128
 
125
- function register(command, emitter) {
129
+ function register(command: string, emitter: PrebuildEmitter) {
126
130
  exporter.register.emitter({ command, emitter, emitters })
127
131
  }
128
132
 
129
- function emit(command) {
133
+ function emit(command: CommandShape) {
130
134
  return exporter.emit.command(command, emitters[command.command], {
131
135
  variableLookup,
132
136
  emitNewWindowHandling,
133
137
  })
134
138
  }
135
139
 
136
- function canEmit(commandName) {
137
- return !!emitters[commandName]
138
- }
139
-
140
- function variableLookup(varName) {
140
+ function variableLookup(varName: string) {
141
141
  return `vars["${varName}"].ToString()`
142
142
  }
143
143
 
144
- function variableSetter(varName, value) {
144
+ function variableSetter(varName: string, value: string) {
145
145
  return varName ? `vars["${varName}"] = ${value};` : ''
146
146
  }
147
147
 
148
148
  function emitWaitForWindow() {
149
- const generateMethodDeclaration = name => {
149
+ const generateMethodDeclaration = (name: string) => {
150
150
  return `public string ${name}(int timeout) {`
151
151
  }
152
152
  const commands = [
@@ -178,7 +178,10 @@ function emitWaitForWindow() {
178
178
  })
179
179
  }
180
180
 
181
- async function emitNewWindowHandling(command, emittedCommand) {
181
+ async function emitNewWindowHandling(
182
+ command: CommandShape,
183
+ emittedCommand: ExportFlexCommandShape
184
+ ) {
182
185
  return Promise.resolve(
183
186
  `vars["WindowHandles"] = driver.WindowHandles;\n${await emittedCommand}\nvars["${
184
187
  command.windowHandleName
@@ -186,7 +189,7 @@ async function emitNewWindowHandling(command, emittedCommand) {
186
189
  )
187
190
  }
188
191
 
189
- function emitAssert(varName, value) {
192
+ function emitAssert(varName: string, value: string) {
190
193
  const _value =
191
194
  value === 'true' || value === 'false'
192
195
  ? exporter.parsers.capitalize(value)
@@ -196,13 +199,13 @@ function emitAssert(varName, value) {
196
199
  )
197
200
  }
198
201
 
199
- function emitAssertAlert(alertText) {
202
+ function emitAssertAlert(alertText: string) {
200
203
  return Promise.resolve(
201
204
  `Assert.That(driver.SwitchTo().Alert().Text, Is.EqualTo("${alertText}"));`
202
205
  )
203
206
  }
204
207
 
205
- function emitAnswerOnNextPrompt(textToSend) {
208
+ function emitAnswerOnNextPrompt(textToSend: string) {
206
209
  const commands = [
207
210
  { level: 0, statement: '{' },
208
211
  { level: 1, statement: 'var Alert = driver.SwitchTo().Alert();' },
@@ -213,7 +216,7 @@ function emitAnswerOnNextPrompt(textToSend) {
213
216
  return Promise.resolve({ commands })
214
217
  }
215
218
 
216
- async function emitCheck(locator) {
219
+ async function emitCheck(locator: string) {
217
220
  const commands = [
218
221
  { level: 0, statement: '{' },
219
222
  {
@@ -238,7 +241,7 @@ function emitChooseOkOnNextConfirmation() {
238
241
  return Promise.resolve(`driver.SwitchTo().Alert().Accept();`)
239
242
  }
240
243
 
241
- async function emitClick(target) {
244
+ async function emitClick(target: string) {
242
245
  return Promise.resolve(
243
246
  `driver.FindElement(${await location.emit(target)}).Click();`
244
247
  )
@@ -248,7 +251,7 @@ async function emitClose() {
248
251
  return Promise.resolve(`driver.Close();`)
249
252
  }
250
253
 
251
- function generateExpressionScript(script) {
254
+ function generateExpressionScript(script: ScriptShape) {
252
255
  const scriptString = script.script.replace(/"/g, "'")
253
256
  return `(Boolean) js.ExecuteScript("return (${scriptString})"${generateScriptArguments(
254
257
  script
@@ -270,7 +273,7 @@ function emitControlFlowElse() {
270
273
  })
271
274
  }
272
275
 
273
- function emitControlFlowElseIf(script) {
276
+ function emitControlFlowElseIf(script: ScriptShape) {
274
277
  return Promise.resolve({
275
278
  commands: [
276
279
  {
@@ -290,7 +293,7 @@ function emitControlFlowEnd() {
290
293
  })
291
294
  }
292
295
 
293
- function emitControlFlowIf(script) {
296
+ function emitControlFlowIf(script: any) {
294
297
  return Promise.resolve({
295
298
  commands: [
296
299
  { level: 0, statement: `if (${generateExpressionScript(script)}) {` },
@@ -299,7 +302,7 @@ function emitControlFlowIf(script) {
299
302
  })
300
303
  }
301
304
 
302
- function emitControlFlowForEach(collectionVarName, iteratorVarName) {
305
+ function emitControlFlowForEach(collectionVarName: string, iteratorVarName: string) {
303
306
  return Promise.resolve({
304
307
  commands: [
305
308
  {
@@ -322,7 +325,7 @@ function emitControlFlowForEach(collectionVarName, iteratorVarName) {
322
325
  })
323
326
  }
324
327
 
325
- function emitControlFlowRepeatIf(script) {
328
+ function emitControlFlowRepeatIf(script: any) {
326
329
  return Promise.resolve({
327
330
  commands: [
328
331
  { level: 0, statement: `} while (${generateExpressionScript(script)});` },
@@ -331,7 +334,7 @@ function emitControlFlowRepeatIf(script) {
331
334
  })
332
335
  }
333
336
 
334
- function emitControlFlowTimes(target) {
337
+ function emitControlFlowTimes(target: any) {
335
338
  const commands = [
336
339
  { level: 0, statement: `var times = ${target};` },
337
340
  { level: 0, statement: 'for(int i = 0; i < times; i++) {' },
@@ -339,7 +342,7 @@ function emitControlFlowTimes(target) {
339
342
  return Promise.resolve({ commands, endingLevelAdjustment: 1 })
340
343
  }
341
344
 
342
- function emitControlFlowWhile(script) {
345
+ function emitControlFlowWhile(script: any) {
343
346
  return Promise.resolve({
344
347
  commands: [
345
348
  { level: 0, statement: `while (${generateExpressionScript(script)}) {` },
@@ -348,7 +351,7 @@ function emitControlFlowWhile(script) {
348
351
  })
349
352
  }
350
353
 
351
- async function emitDoubleClick(target) {
354
+ async function emitDoubleClick(target: any) {
352
355
  const commands = [
353
356
  { level: 0, statement: '{' },
354
357
  {
@@ -364,7 +367,7 @@ async function emitDoubleClick(target) {
364
367
  return Promise.resolve({ commands })
365
368
  }
366
369
 
367
- async function emitDragAndDrop(dragged, dropped) {
370
+ async function emitDragAndDrop(dragged: any, dropped: any) {
368
371
  const commands = [
369
372
  { level: 0, statement: '{' },
370
373
  {
@@ -386,12 +389,12 @@ async function emitDragAndDrop(dragged, dropped) {
386
389
  return Promise.resolve({ commands })
387
390
  }
388
391
 
389
- async function emitEcho(message) {
392
+ async function emitEcho(message: string) {
390
393
  const _message = message.startsWith('vars[') ? message : `"${message}"`
391
394
  return Promise.resolve(`Console.WriteLine(${_message});`)
392
395
  }
393
396
 
394
- async function emitEditContent(locator, content) {
397
+ async function emitEditContent(locator: any, content: any) {
395
398
  const commands = [
396
399
  { level: 0, statement: '{' },
397
400
  {
@@ -409,27 +412,27 @@ async function emitEditContent(locator, content) {
409
412
  return Promise.resolve({ commands })
410
413
  }
411
414
 
412
- async function emitExecuteScript(script, varName) {
415
+ async function emitExecuteScript(script: ScriptShape, varName: string) {
413
416
  const result = `js.ExecuteScript("${script.script}"${generateScriptArguments(
414
417
  script
415
418
  )})`
416
419
  return Promise.resolve(variableSetter(varName, result))
417
420
  }
418
421
 
419
- async function emitExecuteAsyncScript(script, varName) {
422
+ async function emitExecuteAsyncScript(script: ScriptShape, varName: string) {
420
423
  const result = `js.executeAsyncScript("var callback = arguments[arguments.length - 1];${
421
424
  script.script
422
425
  }.then(callback).catch(callback);${generateScriptArguments(script)}")`
423
426
  return Promise.resolve(variableSetter(varName, result))
424
427
  }
425
428
 
426
- function generateScriptArguments(script) {
429
+ function generateScriptArguments(script: ScriptShape) {
427
430
  return `${script.argv.length ? ', ' : ''}${script.argv
428
- .map(varName => `vars["${varName}"]`)
431
+ .map((varName: string) => `vars["${varName}"]`)
429
432
  .join(',')}`
430
433
  }
431
434
 
432
- async function emitMouseDown(locator) {
435
+ async function emitMouseDown(locator: any) {
433
436
  const commands = [
434
437
  { level: 0, statement: '{' },
435
438
  {
@@ -448,7 +451,7 @@ async function emitMouseDown(locator) {
448
451
  return Promise.resolve({ commands })
449
452
  }
450
453
 
451
- async function emitMouseMove(locator) {
454
+ async function emitMouseMove(locator: any) {
452
455
  const commands = [
453
456
  { level: 0, statement: '{' },
454
457
  {
@@ -478,7 +481,7 @@ async function emitMouseOut() {
478
481
  return Promise.resolve({ commands })
479
482
  }
480
483
 
481
- async function emitMouseUp(locator) {
484
+ async function emitMouseUp(locator: any) {
482
485
  const commands = [
483
486
  { level: 0, statement: '{' },
484
487
  {
@@ -497,14 +500,15 @@ async function emitMouseUp(locator) {
497
500
  return Promise.resolve({ commands })
498
501
  }
499
502
 
500
- function emitOpen(target) {
503
+ function emitOpen(target: string) {
501
504
  const url = /^(file|http|https):\/\//.test(target)
502
505
  ? `"${target}"`
503
- : `"${global.baseUrl}${target}"`
506
+ : // @ts-expect-error globals yuck
507
+ `"${global.baseUrl}${target}"`
504
508
  return Promise.resolve(`driver.Navigate().GoToUrl(${url});`)
505
509
  }
506
510
 
507
- async function emitPause(time) {
511
+ async function emitPause(time: any) {
508
512
  const commands = [
509
513
  { level: 0, statement: 'try {' },
510
514
  { level: 1, statement: `Thread.Sleep(${time});` },
@@ -515,24 +519,26 @@ async function emitPause(time) {
515
519
  return Promise.resolve({ commands })
516
520
  }
517
521
 
518
- async function emitRun(testName) {
522
+ async function emitRun(testName: string) {
519
523
  return Promise.resolve(`${exporter.parsers.sanitizeName(testName)}();`)
520
524
  }
521
525
 
522
- async function emitRunScript(script) {
526
+ async function emitRunScript(script: ScriptShape) {
523
527
  return Promise.resolve(
524
528
  `js.ExecuteScript("${script.script}${generateScriptArguments(script)}");`
525
529
  )
526
530
  }
527
531
 
528
- async function emitSetWindowSize(size) {
532
+ async function emitSetWindowSize(size: {
533
+ split: (arg0: string) => [any, any]
534
+ }) {
529
535
  const [width, height] = size.split('x')
530
536
  return Promise.resolve(
531
537
  `driver.Manage().Window.Size = new System.Drawing.Size(${width}, ${height});`
532
538
  )
533
539
  }
534
540
 
535
- async function emitSelect(selectElement, option) {
541
+ async function emitSelect(selectElement: any, option: any) {
536
542
  const commands = [
537
543
  { level: 0, statement: '{' },
538
544
  {
@@ -549,16 +555,16 @@ async function emitSelect(selectElement, option) {
549
555
  },
550
556
  { level: 0, statement: '}' },
551
557
  ]
552
- return Promise.resolve({ commands })
558
+ return { commands }
553
559
  }
554
560
 
555
- async function emitSelectFrame(frameLocation) {
561
+ async function emitSelectFrame(frameLocation: string) {
556
562
  if (frameLocation === 'relative=top' || frameLocation === 'relative=parent') {
557
563
  return Promise.resolve('driver.SwitchTo().DefaultContent();')
558
564
  } else if (/^index=/.test(frameLocation)) {
559
565
  return Promise.resolve(
560
566
  `driver.SwitchTo().Frame(${Math.floor(
561
- frameLocation.split('index=')[1]
567
+ Number(frameLocation.split('index=')[1])
562
568
  )});`
563
569
  )
564
570
  } else {
@@ -578,7 +584,7 @@ async function emitSelectFrame(frameLocation) {
578
584
  }
579
585
  }
580
586
 
581
- async function emitSelectWindow(windowLocation) {
587
+ async function emitSelectWindow(windowLocation: string) {
582
588
  if (/^handle=/.test(windowLocation)) {
583
589
  return Promise.resolve(
584
590
  `driver.SwitchTo().Window(${windowLocation.split('handle=')[1]});`
@@ -626,14 +632,14 @@ async function emitSelectWindow(windowLocation) {
626
632
  }
627
633
  }
628
634
 
629
- function generateSendKeysInput(value) {
630
- if (typeof value === 'object') {
635
+ function generateSendKeysInput(value: string | string[]) {
636
+ if (Array.isArray(value)) {
631
637
  return value
632
- .map(s => {
638
+ .map((s) => {
633
639
  if (s.startsWith('vars[')) {
634
640
  return s
635
641
  } else if (s.startsWith('Key[')) {
636
- const key = s.match(/\['(.*)'\]/)[1]
642
+ const key = (s.match(/\['(.*)'\]/) as RegExpMatchArray)[1]
637
643
  return `Keys.${exporter.parsers.capitalize(key.toLowerCase())}`
638
644
  } else {
639
645
  return `"${s}"`
@@ -649,7 +655,7 @@ function generateSendKeysInput(value) {
649
655
  }
650
656
  }
651
657
 
652
- async function emitSendKeys(target, value) {
658
+ async function emitSendKeys(target: any, value: any) {
653
659
  return Promise.resolve(
654
660
  `driver.FindElement(${await location.emit(
655
661
  target
@@ -663,13 +669,13 @@ function emitSetSpeed() {
663
669
  )
664
670
  }
665
671
 
666
- async function emitStore(value, varName) {
672
+ async function emitStore(value: any, varName: string) {
667
673
  return Promise.resolve(variableSetter(varName, `"${value}"`))
668
674
  }
669
675
 
670
- async function emitStoreAttribute(locator, varName) {
676
+ async function emitStoreAttribute(locator: string | string[], varName: string) {
671
677
  const attributePos = locator.lastIndexOf('@')
672
- const elementLocator = locator.slice(0, attributePos)
678
+ const elementLocator = locator.slice(0, attributePos) as string
673
679
  const attributeName = locator.slice(attributePos + 1)
674
680
  const commands = [
675
681
  { level: 0, statement: '{' },
@@ -689,44 +695,44 @@ async function emitStoreAttribute(locator, varName) {
689
695
  return Promise.resolve({ commands })
690
696
  }
691
697
 
692
- async function emitStoreJson(_json, _varName) {
698
+ async function emitStoreJson(_json: any, _varName: string) {
693
699
  return Promise.resolve(
694
700
  'throw new System.Exception("The `storeJson` command is not yet implemented for this language.");'
695
701
  )
696
702
  }
697
703
 
698
- async function emitStoreText(locator, varName) {
704
+ async function emitStoreText(locator: any, varName: string) {
699
705
  const result = `driver.FindElement(${await location.emit(locator)}).Text`
700
706
  return Promise.resolve(variableSetter(varName, result))
701
707
  }
702
708
 
703
- async function emitStoreTitle(_, varName) {
709
+ async function emitStoreTitle(_: any, varName: string) {
704
710
  return Promise.resolve(variableSetter(varName, 'driver.Title'))
705
711
  }
706
712
 
707
- async function emitStoreValue(locator, varName) {
713
+ async function emitStoreValue(locator: any, varName: string) {
708
714
  const result = `driver.FindElement(${await location.emit(
709
715
  locator
710
716
  )}).GetAttribute("value")`
711
717
  return Promise.resolve(variableSetter(varName, result))
712
718
  }
713
719
 
714
- async function emitStoreWindowHandle(varName) {
720
+ async function emitStoreWindowHandle(varName: string) {
715
721
  return Promise.resolve(variableSetter(varName, 'driver.CurrentWindowHandle'))
716
722
  }
717
723
 
718
- async function emitStoreXpathCount(locator, varName) {
724
+ async function emitStoreXpathCount(locator: any, varName: string) {
719
725
  const result = `driver.FindElements(${await location.emit(locator)}).Count`
720
726
  return Promise.resolve(variableSetter(varName, result))
721
727
  }
722
728
 
723
- async function emitSubmit(_locator) {
729
+ async function emitSubmit(_locator: any) {
724
730
  return Promise.resolve(
725
731
  `throw new System.Exception("\`submit\` is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.");`
726
732
  )
727
733
  }
728
734
 
729
- async function emitType(target, value) {
735
+ async function emitType(target: any, value: any) {
730
736
  return Promise.resolve(
731
737
  `driver.FindElement(${await location.emit(
732
738
  target
@@ -734,7 +740,7 @@ async function emitType(target, value) {
734
740
  )
735
741
  }
736
742
 
737
- async function emitUncheck(locator) {
743
+ async function emitUncheck(locator: any) {
738
744
  const commands = [
739
745
  { level: 0, statement: '{' },
740
746
  {
@@ -751,13 +757,13 @@ async function emitUncheck(locator) {
751
757
  return Promise.resolve({ commands })
752
758
  }
753
759
 
754
- async function emitVerifyChecked(locator) {
760
+ async function emitVerifyChecked(locator: any) {
755
761
  return Promise.resolve(
756
762
  `Assert.True(driver.FindElement(${await location.emit(locator)}).Selected);`
757
763
  )
758
764
  }
759
765
 
760
- async function emitVerifyEditable(locator) {
766
+ async function emitVerifyEditable(locator: any) {
761
767
  const commands = [
762
768
  { level: 0, statement: '{' },
763
769
  {
@@ -777,7 +783,7 @@ async function emitVerifyEditable(locator) {
777
783
  return Promise.resolve({ commands })
778
784
  }
779
785
 
780
- async function emitVerifyElementPresent(locator) {
786
+ async function emitVerifyElementPresent(locator: any) {
781
787
  const commands = [
782
788
  {
783
789
  level: 0,
@@ -790,7 +796,7 @@ async function emitVerifyElementPresent(locator) {
790
796
  return Promise.resolve({ commands })
791
797
  }
792
798
 
793
- async function emitVerifyElementNotPresent(locator) {
799
+ async function emitVerifyElementNotPresent(locator: any) {
794
800
  const commands = [
795
801
  { level: 0, statement: '{' },
796
802
  {
@@ -805,7 +811,7 @@ async function emitVerifyElementNotPresent(locator) {
805
811
  return Promise.resolve({ commands })
806
812
  }
807
813
 
808
- async function emitVerifyNotChecked(locator) {
814
+ async function emitVerifyNotChecked(locator: any) {
809
815
  return Promise.resolve(
810
816
  `Assert.False(driver.FindElement(${await location.emit(
811
817
  locator
@@ -813,7 +819,7 @@ async function emitVerifyNotChecked(locator) {
813
819
  )
814
820
  }
815
821
 
816
- async function emitVerifyNotEditable(locator) {
822
+ async function emitVerifyNotEditable(locator: any) {
817
823
  const commands = [
818
824
  { level: 0, statement: '{' },
819
825
  {
@@ -833,7 +839,7 @@ async function emitVerifyNotEditable(locator) {
833
839
  return Promise.resolve({ commands })
834
840
  }
835
841
 
836
- async function emitVerifyNotSelectedValue(locator, expectedValue) {
842
+ async function emitVerifyNotSelectedValue(locator: any, expectedValue: string) {
837
843
  const commands = [
838
844
  { level: 0, statement: '{' },
839
845
  {
@@ -853,14 +859,14 @@ async function emitVerifyNotSelectedValue(locator, expectedValue) {
853
859
  return Promise.resolve({ commands })
854
860
  }
855
861
 
856
- async function emitVerifyNotText(locator, text) {
862
+ async function emitVerifyNotText(locator: any, text: string) {
857
863
  const result = `driver.FindElement(${await location.emit(locator)}).Text`
858
864
  return Promise.resolve(
859
865
  `Assert.That(${result}, Is.Not.EqualTo("${exporter.emit.text(text)}"));`
860
866
  )
861
867
  }
862
868
 
863
- async function emitVerifySelectedLabel(locator, labelValue) {
869
+ async function emitVerifySelectedLabel(locator: any, labelValue: any) {
864
870
  const commands = [
865
871
  { level: 0, statement: '{' },
866
872
  {
@@ -890,11 +896,11 @@ async function emitVerifySelectedLabel(locator, labelValue) {
890
896
  })
891
897
  }
892
898
 
893
- async function emitVerifySelectedValue(locator, value) {
899
+ async function emitVerifySelectedValue(locator: any, value: any) {
894
900
  return emitVerifyValue(locator, value)
895
901
  }
896
902
 
897
- async function emitVerifyText(locator, text) {
903
+ async function emitVerifyText(locator: any, text: string) {
898
904
  return Promise.resolve(
899
905
  `Assert.That(driver.FindElement(${await location.emit(
900
906
  locator
@@ -902,7 +908,7 @@ async function emitVerifyText(locator, text) {
902
908
  )
903
909
  }
904
910
 
905
- async function emitVerifyValue(locator, value) {
911
+ async function emitVerifyValue(locator: any, value: any) {
906
912
  const commands = [
907
913
  { level: 0, statement: '{' },
908
914
  {
@@ -917,11 +923,11 @@ async function emitVerifyValue(locator, value) {
917
923
  return Promise.resolve({ commands })
918
924
  }
919
925
 
920
- async function emitVerifyTitle(title) {
926
+ async function emitVerifyTitle(title: any) {
921
927
  return Promise.resolve(`Assert.That(driver.Title, Is.EqualTo("${title}"));`)
922
928
  }
923
929
 
924
- async function emitWaitForElementEditable(locator, timeout) {
930
+ async function emitWaitForElementEditable(locator: any, timeout: number) {
925
931
  const commands = [
926
932
  { level: 0, statement: '{' },
927
933
  {
@@ -941,7 +947,7 @@ async function emitWaitForElementEditable(locator, timeout) {
941
947
  return Promise.resolve({ commands })
942
948
  }
943
949
 
944
- async function emitWaitForText(locator, text) {
950
+ async function emitWaitForText(locator: any, text: any) {
945
951
  const timeout = 30000
946
952
  const commands = [
947
953
  { level: 0, statement: '{' },
@@ -966,7 +972,7 @@ function skip() {
966
972
  return Promise.resolve('')
967
973
  }
968
974
 
969
- async function emitWaitForElementPresent(locator, timeout) {
975
+ async function emitWaitForElementPresent(locator: any, timeout: number) {
970
976
  const commands = [
971
977
  { level: 0, statement: '{' },
972
978
  {
@@ -986,7 +992,7 @@ async function emitWaitForElementPresent(locator, timeout) {
986
992
  return Promise.resolve({ commands })
987
993
  }
988
994
 
989
- async function emitWaitForElementVisible(locator, timeout) {
995
+ async function emitWaitForElementVisible(locator: any, timeout: number) {
990
996
  const commands = [
991
997
  { level: 0, statement: '{' },
992
998
  {
@@ -1008,7 +1014,7 @@ async function emitWaitForElementVisible(locator, timeout) {
1008
1014
  })
1009
1015
  }
1010
1016
 
1011
- async function emitWaitForElementNotEditable(locator, timeout) {
1017
+ async function emitWaitForElementNotEditable(locator: any, timeout: number) {
1012
1018
  const commands = [
1013
1019
  { level: 0, statement: '{' },
1014
1020
  {
@@ -1030,7 +1036,7 @@ async function emitWaitForElementNotEditable(locator, timeout) {
1030
1036
  })
1031
1037
  }
1032
1038
 
1033
- async function emitWaitForElementNotPresent(locator, timeout) {
1039
+ async function emitWaitForElementNotPresent(locator: any, timeout: number) {
1034
1040
  const commands = [
1035
1041
  { level: 0, statement: '{' },
1036
1042
  {
@@ -1052,7 +1058,7 @@ async function emitWaitForElementNotPresent(locator, timeout) {
1052
1058
  })
1053
1059
  }
1054
1060
 
1055
- async function emitWaitForElementNotVisible(locator, timeout) {
1061
+ async function emitWaitForElementNotVisible(locator: any, timeout: number) {
1056
1062
  const commands = [
1057
1063
  { level: 0, statement: '{' },
1058
1064
  {
@@ -1078,7 +1084,6 @@ export default {
1078
1084
  emitters,
1079
1085
  variableLookup,
1080
1086
  variableSetter,
1081
- canEmit,
1082
1087
  emit,
1083
1088
  register,
1084
1089
  extras: { emitWaitForWindow, emitNewWindowHandling },
@@ -15,17 +15,21 @@
15
15
  // specific language governing permissions and limitations
16
16
  // under the License.
17
17
 
18
+
18
19
  import Command from './command'
19
20
  import location from './location'
20
21
 
21
- const opts = {}
22
- opts.fileExtension = '.cs'
23
- opts.commandPrefixPadding = ' '
24
- opts.terminatingKeyword = '}'
25
- opts.commentPrefix = '//'
26
-
27
- module.exports = {
22
+ const exportFormat = {
28
23
  Command,
29
24
  location,
30
- opts,
31
- }
25
+ opts: {
26
+ fileExtension: '.cs',
27
+ commandPrefixPadding: ' ',
28
+ terminatingKeyword: '}',
29
+ commentPrefix: '//',
30
+ },
31
+ } as const
32
+
33
+ export default exportFormat;
34
+ export {default as Command} from './command'
35
+ export {default as location} from './location'
@@ -15,9 +15,10 @@
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 { codeExport as exporter } from '@seleniumhq/side-code-export'
19
+ import { LocationEmitters } from '@seleniumhq/side-code-export/src/code-export/emit'
19
20
 
20
- const emitters = {
21
+ const emitters: LocationEmitters = {
21
22
  id: emitId,
22
23
  name: emitName,
23
24
  link: emitLink,
@@ -27,7 +28,7 @@ const emitters = {
27
28
  xpath: emitXpath,
28
29
  }
29
30
 
30
- export function emit(location) {
31
+ export function emit(location: string) {
31
32
  return exporter.emit.location(location, emitters)
32
33
  }
33
34
 
@@ -35,26 +36,26 @@ export default {
35
36
  emit,
36
37
  }
37
38
 
38
- function emitId(selector) {
39
+ function emitId(selector: string) {
39
40
  return Promise.resolve(`By.Id("${selector}")`)
40
41
  }
41
42
 
42
- function emitName(selector) {
43
+ function emitName(selector: string) {
43
44
  return Promise.resolve(`By.Name("${selector}")`)
44
45
  }
45
46
 
46
- function emitLink(selector) {
47
+ function emitLink(selector: string) {
47
48
  return Promise.resolve(`By.LinkText("${selector}")`)
48
49
  }
49
50
 
50
- function emitPartialLinkText(selector) {
51
+ function emitPartialLinkText(selector: string) {
51
52
  return Promise.resolve(`By.PartialLinkText("${selector}")`)
52
53
  }
53
54
 
54
- function emitCss(selector) {
55
+ function emitCss(selector: string) {
55
56
  return Promise.resolve(`By.CssSelector("${selector}")`)
56
57
  }
57
58
 
58
- function emitXpath(selector) {
59
+ function emitXpath(selector: string) {
59
60
  return Promise.resolve(`By.XPath("${selector}")`)
60
61
  }