@seleniumhq/code-export-python-pytest 3.16.0 → 3.17.4

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.
package/dist/command.js DELETED
@@ -1,882 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.emitters = void 0;
7
-
8
- var _sideUtils = require("@seleniumhq/side-utils");
9
-
10
- var _location = _interopRequireDefault(require("./location"));
11
-
12
- var _selection = _interopRequireDefault(require("./selection"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- // Licensed to the Software Freedom Conservancy (SFC) under one
17
- // or more contributor license agreements. See the NOTICE file
18
- // distributed with this work for additional information
19
- // regarding copyright ownership. The SFC licenses this file
20
- // to you under the Apache License, Version 2.0 (the
21
- // "License"); you may not use this file except in compliance
22
- // with the License. You may obtain a copy of the License at
23
- //
24
- // http://www.apache.org/licenses/LICENSE-2.0
25
- //
26
- // Unless required by applicable law or agreed to in writing,
27
- // software distributed under the License is distributed on an
28
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
29
- // KIND, either express or implied. See the License for the
30
- // specific language governing permissions and limitations
31
- // under the License.
32
- const emitters = {
33
- addSelection: emitSelect,
34
- answerOnNextPrompt: skip,
35
- assert: emitAssert,
36
- assertAlert: emitAssertAlert,
37
- assertChecked: emitVerifyChecked,
38
- assertConfirmation: emitAssertAlert,
39
- assertEditable: emitVerifyEditable,
40
- assertElementPresent: emitVerifyElementPresent,
41
- assertElementNotPresent: emitVerifyElementNotPresent,
42
- assertNotChecked: emitVerifyNotChecked,
43
- assertNotEditable: emitVerifyNotEditable,
44
- assertNotSelectedValue: emitVerifyNotSelectedValue,
45
- assertNotText: emitVerifyNotText,
46
- assertPrompt: emitAssertAlert,
47
- assertSelectedLabel: emitVerifySelectedLabel,
48
- assertSelectedValue: emitVerifyValue,
49
- assertValue: emitVerifyValue,
50
- assertText: emitVerifyText,
51
- assertTitle: emitVerifyTitle,
52
- check: emitCheck,
53
- chooseCancelOnNextConfirmation: skip,
54
- chooseCancelOnNextPrompt: skip,
55
- chooseOkOnNextConfirmation: skip,
56
- click: emitClick,
57
- clickAt: emitClick,
58
- close: emitClose,
59
- debugger: skip,
60
- do: emitControlFlowDo,
61
- doubleClick: emitDoubleClick,
62
- doubleClickAt: emitDoubleClick,
63
- dragAndDropToObject: emitDragAndDrop,
64
- echo: emitEcho,
65
- editContent: emitEditContent,
66
- else: emitControlFlowElse,
67
- elseIf: emitControlFlowElseIf,
68
- end: emitControlFlowEnd,
69
- executeScript: emitExecuteScript,
70
- executeAsyncScript: emitExecuteAsyncScript,
71
- forEach: emitControlFlowForEach,
72
- if: emitControlFlowIf,
73
- mouseDown: emitMouseDown,
74
- mouseDownAt: emitMouseDown,
75
- mouseMove: emitMouseMove,
76
- mouseMoveAt: emitMouseMove,
77
- mouseOver: emitMouseMove,
78
- mouseOut: emitMouseOut,
79
- mouseUp: emitMouseUp,
80
- mouseUpAt: emitMouseUp,
81
- open: emitOpen,
82
- pause: emitPause,
83
- removeSelection: emitSelect,
84
- repeatIf: emitControlFlowRepeatIf,
85
- run: emitRun,
86
- runScript: emitRunScript,
87
- select: emitSelect,
88
- selectFrame: emitSelectFrame,
89
- selectWindow: emitSelectWindow,
90
- sendKeys: emitSendKeys,
91
- setSpeed: emitSetSpeed,
92
- setWindowSize: emitSetWindowSize,
93
- store: emitStore,
94
- storeAttribute: emitStoreAttribute,
95
- storeJson: emitStoreJson,
96
- storeText: emitStoreText,
97
- storeTitle: emitStoreTitle,
98
- storeValue: emitStoreValue,
99
- storeWindowHandle: emitStoreWindowHandle,
100
- storeXpathCount: emitStoreXpathCount,
101
- submit: emitSubmit,
102
- times: emitControlFlowTimes,
103
- type: emitType,
104
- uncheck: emitUncheck,
105
- verify: emitAssert,
106
- verifyChecked: emitVerifyChecked,
107
- verifyEditable: emitVerifyEditable,
108
- verifyElementPresent: emitVerifyElementPresent,
109
- verifyElementNotPresent: emitVerifyElementNotPresent,
110
- verifyNotChecked: emitVerifyNotChecked,
111
- verifyNotEditable: emitVerifyNotEditable,
112
- verifyNotSelectedValue: emitVerifyNotSelectedValue,
113
- verifyNotText: emitVerifyNotText,
114
- verifySelectedLabel: emitVerifySelectedLabel,
115
- verifySelectedValue: emitVerifyValue,
116
- verifyText: emitVerifyText,
117
- verifyTitle: emitVerifyTitle,
118
- verifyValue: emitVerifyValue,
119
- waitForElementEditable: emitWaitForElementEditable,
120
- waitForElementPresent: emitWaitForElementPresent,
121
- waitForElementVisible: emitWaitForElementVisible,
122
- waitForElementNotEditable: emitWaitForElementNotEditable,
123
- waitForElementNotPresent: emitWaitForElementNotPresent,
124
- waitForElementNotVisible: emitWaitForElementNotVisible,
125
- webdriverAnswerOnVisiblePrompt: emitAnswerOnNextPrompt,
126
- webdriverChooseCancelOnVisibleConfirmation: emitChooseCancelOnNextConfirmation,
127
- webdriverChooseCancelOnVisiblePrompt: emitChooseCancelOnNextConfirmation,
128
- webdriverChooseOkOnVisibleConfirmation: emitChooseOkOnNextConfirmation,
129
- while: emitControlFlowWhile
130
- };
131
- exports.emitters = emitters;
132
-
133
- _sideUtils.codeExport.register.preprocessors(emitters);
134
-
135
- function register(command, emitter) {
136
- _sideUtils.codeExport.register.emitter({
137
- command,
138
- emitter,
139
- emitters
140
- });
141
- }
142
-
143
- function emit(command) {
144
- return _sideUtils.codeExport.emit.command(command, emitters[command.command], {
145
- variableLookup,
146
- emitNewWindowHandling
147
- });
148
- }
149
-
150
- function canEmit(commandName) {
151
- return !!emitters[commandName];
152
- }
153
-
154
- function variableLookup(varName) {
155
- return `self.vars["${varName}"]`;
156
- }
157
-
158
- function variableSetter(varName, value) {
159
- return varName ? `self.vars["${varName}"] = ${value}` : '';
160
- }
161
-
162
- function emitWaitForWindow() {
163
- const generateMethodDeclaration = name => {
164
- return `def ${name}(self, timeout = 2):`;
165
- };
166
-
167
- const commands = [{
168
- level: 0,
169
- statement: 'time.sleep(round(timeout / 1000))'
170
- }, {
171
- level: 0,
172
- statement: 'wh_now = self.driver.window_handles'
173
- }, {
174
- level: 0,
175
- statement: 'wh_then = self.vars["window_handles"]'
176
- }, {
177
- level: 0,
178
- statement: 'if len(wh_now) > len(wh_then):'
179
- }, {
180
- level: 1,
181
- statement: 'return set(wh_now).difference(set(wh_then)).pop()'
182
- }];
183
- return Promise.resolve({
184
- name: 'wait_for_window',
185
- commands,
186
- generateMethodDeclaration
187
- });
188
- }
189
-
190
- async function emitNewWindowHandling(command, emittedCommand) {
191
- return Promise.resolve(`self.vars["window_handles"] = self.driver.window_handles\n${await emittedCommand}\nself.vars["${command.windowHandleName}"] = self.wait_for_window(${command.windowTimeout})`);
192
- }
193
-
194
- function emitAssert(varName, value) {
195
- let _value;
196
-
197
- if (value === 'true' || value === 'false') {
198
- _value = _sideUtils.codeExport.parsers.capitalize(value);
199
- } else if (value === '0' || !!Number(value)) {
200
- _value = value;
201
- }
202
-
203
- const result = _value ? `assert(self.vars["${varName}"] == ${_value})` : `assert(self.vars["${varName}"] == "${value}")`;
204
- return Promise.resolve(result);
205
- }
206
-
207
- function emitAssertAlert(alertText) {
208
- return Promise.resolve(`assert self.driver.switch_to.alert.text == "${alertText}"`);
209
- }
210
-
211
- function emitAnswerOnNextPrompt(textToSend) {
212
- const commands = [{
213
- level: 0,
214
- statement: 'alert = self.driver.switch_to.alert'
215
- }, {
216
- level: 0,
217
- statement: `alert.send_keys("${textToSend}")`
218
- }, {
219
- level: 0,
220
- statement: 'alert.accept()'
221
- }];
222
- return Promise.resolve({
223
- commands
224
- });
225
- }
226
-
227
- async function emitCheck(locator) {
228
- const commands = [{
229
- level: 0,
230
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
231
- }, {
232
- level: 0,
233
- statement: 'if element.is_selected() != True: element.click()'
234
- }];
235
- return Promise.resolve({
236
- commands
237
- });
238
- }
239
-
240
- function emitChooseCancelOnNextConfirmation() {
241
- return Promise.resolve(`self.driver.switch_to.alert.dismiss()`);
242
- }
243
-
244
- function emitChooseOkOnNextConfirmation() {
245
- return Promise.resolve(`self.driver.switch_to.alert.accept()`);
246
- }
247
-
248
- async function emitClick(target) {
249
- return Promise.resolve(`self.driver.find_element(${await _location.default.emit(target)}).click()`);
250
- }
251
-
252
- async function emitClose() {
253
- return Promise.resolve(`self.driver.close()`);
254
- }
255
-
256
- function generateExpressionScript(script) {
257
- return `self.driver.execute_script("return (${script.script})"${generateScriptArguments(script)})`;
258
- }
259
-
260
- function generateScriptArguments(script) {
261
- return `${script.argv.length ? ', ' : ''}${script.argv.map(varName => `self.vars["${varName}"]`).join(',')}`;
262
- }
263
-
264
- function emitControlFlowDo() {
265
- return Promise.resolve({
266
- commands: [{
267
- level: 0,
268
- statement: 'condition = True'
269
- }, {
270
- level: 0,
271
- statement: 'while condition:'
272
- }],
273
- endingLevelAdjustment: 1
274
- });
275
- }
276
-
277
- function emitControlFlowElse() {
278
- return Promise.resolve({
279
- commands: [{
280
- level: 0,
281
- statement: 'else:'
282
- }],
283
- startingLevelAdjustment: -1,
284
- endingLevelAdjustment: +1
285
- });
286
- }
287
-
288
- function emitControlFlowElseIf(script) {
289
- return Promise.resolve({
290
- commands: [{
291
- level: 0,
292
- statement: `elif ${generateExpressionScript(script)}:`
293
- }],
294
- startingLevelAdjustment: -1,
295
- endingLevelAdjustment: +1
296
- });
297
- }
298
-
299
- function emitControlFlowEnd() {
300
- return Promise.resolve({
301
- commands: [{
302
- level: 0,
303
- statement: ``
304
- }],
305
- startingLevelAdjustment: -1,
306
- skipEmitting: true
307
- });
308
- }
309
-
310
- function emitControlFlowIf(script) {
311
- return Promise.resolve({
312
- commands: [{
313
- level: 0,
314
- statement: `if ${generateExpressionScript(script)}:`
315
- }],
316
- endingLevelAdjustment: 1
317
- });
318
- }
319
-
320
- function emitControlFlowForEach(collectionVarName, iteratorVarName) {
321
- return Promise.resolve({
322
- commands: [{
323
- level: 0,
324
- statement: `collection = self.vars["${collectionVarName}"]`
325
- }, {
326
- level: 0,
327
- statement: `for entry in collection:`
328
- }, {
329
- level: 1,
330
- statement: `self.vars["${iteratorVarName}"] = entry`
331
- }]
332
- });
333
- }
334
-
335
- function emitControlFlowRepeatIf(script) {
336
- return Promise.resolve({
337
- commands: [{
338
- level: 0,
339
- statement: `condition = ${generateExpressionScript(script)}`
340
- }],
341
- endingLevelAdjustment: -1
342
- });
343
- }
344
-
345
- function emitControlFlowTimes(target) {
346
- const commands = [{
347
- level: 0,
348
- statement: `for i in range(0, ${target}):`
349
- }];
350
- return Promise.resolve({
351
- commands,
352
- endingLevelAdjustment: 1
353
- });
354
- }
355
-
356
- function emitControlFlowWhile(script) {
357
- return Promise.resolve({
358
- commands: [{
359
- level: 0,
360
- statement: `while ${generateExpressionScript(script)}:`
361
- }],
362
- endingLevelAdjustment: 1
363
- });
364
- }
365
-
366
- async function emitDoubleClick(target) {
367
- const commands = [{
368
- level: 0,
369
- statement: `element = self.driver.find_element(${await _location.default.emit(target)})`
370
- }, {
371
- level: 0,
372
- statement: 'actions = ActionChains(self.driver)'
373
- }, {
374
- level: 0,
375
- statement: 'actions.double_click(element).perform()'
376
- }];
377
- return Promise.resolve({
378
- commands
379
- });
380
- }
381
-
382
- async function emitDragAndDrop(dragged, dropped) {
383
- const commands = [{
384
- level: 0,
385
- statement: `dragged = self.driver.find_element(${await _location.default.emit(dragged)})`
386
- }, {
387
- level: 0,
388
- statement: `dropped = self.driver.find_element(${await _location.default.emit(dropped)})`
389
- }, {
390
- level: 0,
391
- statement: 'actions = ActionChains(self.driver)'
392
- }, {
393
- level: 0,
394
- statement: 'actions.drag_and_drop(dragged, dropped).perform()'
395
- }];
396
- return Promise.resolve({
397
- commands
398
- });
399
- }
400
-
401
- async function emitEcho(message) {
402
- const _message = message.startsWith('self.vars[') ? message : `"${message}"`;
403
-
404
- return Promise.resolve(`print(str(${_message}))`);
405
- }
406
-
407
- async function emitEditContent(locator, content) {
408
- const commands = [{
409
- level: 0,
410
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
411
- }, {
412
- level: 0,
413
- statement: `self.driver.execute_script("if(arguments[0].contentEditable === 'true') {arguments[0].innerText = '${content}'}", element)`
414
- }];
415
- return Promise.resolve({
416
- commands
417
- });
418
- }
419
-
420
- async function emitExecuteScript(script, varName) {
421
- const scriptString = script.script.replace(/"/g, "'");
422
- const result = `self.driver.execute_script("${scriptString}"${generateScriptArguments(script)})`;
423
- return Promise.resolve(variableSetter(varName, result));
424
- }
425
-
426
- async function emitExecuteAsyncScript(script, varName) {
427
- const result = `self.driver.execute_async_script("var callback = arguments[arguments.length - 1];${script.script}.then(callback).catch(callback);${generateScriptArguments(script)}")`;
428
- return Promise.resolve(variableSetter(varName, result));
429
- }
430
-
431
- async function emitMouseDown(locator) {
432
- const commands = [{
433
- level: 0,
434
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
435
- }, {
436
- level: 0,
437
- statement: 'actions = ActionChains(self.driver)'
438
- }, {
439
- level: 0,
440
- statement: 'actions.move_to_element(element).click_and_hold().perform()'
441
- }];
442
- return Promise.resolve({
443
- commands
444
- });
445
- }
446
-
447
- async function emitMouseMove(locator) {
448
- const commands = [{
449
- level: 0,
450
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
451
- }, {
452
- level: 0,
453
- statement: 'actions = ActionChains(self.driver)'
454
- }, {
455
- level: 0,
456
- statement: 'actions.move_to_element(element).perform()'
457
- }];
458
- return Promise.resolve({
459
- commands
460
- });
461
- }
462
-
463
- async function emitMouseOut() {
464
- const commands = [{
465
- level: 0,
466
- statement: `element = self.driver.find_element(By.CSS_SELECTOR, "body")`
467
- }, {
468
- level: 0,
469
- statement: 'actions = ActionChains(self.driver)'
470
- }, {
471
- level: 0,
472
- statement: 'actions.move_to_element(element, 0, 0).perform()'
473
- }];
474
- return Promise.resolve({
475
- commands
476
- });
477
- }
478
-
479
- async function emitMouseUp(locator) {
480
- const commands = [{
481
- level: 0,
482
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
483
- }, {
484
- level: 0,
485
- statement: 'actions = ActionChains(self.driver)'
486
- }, {
487
- level: 0,
488
- statement: 'actions.move_to_element(element).release().perform()'
489
- }];
490
- return Promise.resolve({
491
- commands
492
- });
493
- }
494
-
495
- function emitOpen(target) {
496
- const url = /^(file|http|https):\/\//.test(target) ? `"${target}"` : `"${global.baseUrl}${target}"`;
497
- return Promise.resolve(`self.driver.get(${url})`);
498
- }
499
-
500
- async function emitPause(time) {
501
- const commands = [{
502
- level: 0,
503
- statement: `time.sleep(${time})`
504
- }];
505
- return Promise.resolve({
506
- commands
507
- });
508
- }
509
-
510
- async function emitRun(testName) {
511
- return Promise.resolve(`self.${_sideUtils.codeExport.parsers.sanitizeName(testName)}()`);
512
- }
513
-
514
- async function emitRunScript(script) {
515
- return Promise.resolve(`self.driver.execute_script("${script.script}${generateScriptArguments(script)}")`);
516
- }
517
-
518
- async function emitSetWindowSize(size) {
519
- const [width, height] = size.split('x');
520
- return Promise.resolve(`self.driver.set_window_size(${width}, ${height})`);
521
- }
522
-
523
- async function emitSelect(selectElement, option) {
524
- const commands = [{
525
- level: 0,
526
- statement: `dropdown = self.driver.find_element(${await _location.default.emit(selectElement)})`
527
- }, {
528
- level: 0,
529
- statement: `dropdown.find_element(${await _selection.default.emit(option)}).click()`
530
- }];
531
- return Promise.resolve({
532
- commands
533
- });
534
- }
535
-
536
- async function emitSelectFrame(frameLocation) {
537
- if (frameLocation === 'relative=top' || frameLocation === 'relative=parent') {
538
- return Promise.resolve('self.driver.switch_to.default_content()');
539
- } else if (/^index=/.test(frameLocation)) {
540
- return Promise.resolve(`self.driver.switch_to.frame(${Math.floor(frameLocation.split('index=')[1])})`);
541
- } else {
542
- return Promise.resolve({
543
- commands: [{
544
- level: 0,
545
- statement: `element = self.driver.find_element(${await _location.default.emit(frameLocation)})`
546
- }, {
547
- level: 0,
548
- statement: 'self.driver.switch_to.frame(element)'
549
- }]
550
- });
551
- }
552
- }
553
-
554
- async function emitSelectWindow(windowLocation) {
555
- if (/^handle=/.test(windowLocation)) {
556
- return Promise.resolve(`self.driver.switch_to.window(${windowLocation.split('handle=')[1]})`);
557
- } else if (/^name=/.test(windowLocation)) {
558
- return Promise.resolve(`self.driver.switch_to.window("${windowLocation.split('name=')[1]}")`);
559
- } else if (/^win_ser_/.test(windowLocation)) {
560
- if (windowLocation === 'win_ser_local') {
561
- return Promise.resolve({
562
- commands: [{
563
- level: 0,
564
- statement: 'self.driver.switch_to.window(self.driver.window_handles[0])'
565
- }]
566
- });
567
- } else {
568
- const index = parseInt(windowLocation.substr('win_ser_'.length));
569
- return Promise.resolve({
570
- commands: [{
571
- level: 0,
572
- statement: `self.driver.switch_to.window(self.driver.window_handles[${index}])`
573
- }]
574
- });
575
- }
576
- } else {
577
- return Promise.reject(new Error('Can only emit `select window` using handles'));
578
- }
579
- }
580
-
581
- function generateSendKeysInput(value) {
582
- if (typeof value === 'object') {
583
- return value.map(s => {
584
- if (s.startsWith('self.vars[')) {
585
- return s;
586
- } else if (s.startsWith('Key[')) {
587
- const key = s.match(/\['(.*)'\]/)[1];
588
- return `Keys.${key}`;
589
- } else {
590
- return `"${s}"`;
591
- }
592
- }).join(', ');
593
- } else {
594
- if (value.startsWith('self.vars[')) {
595
- return value;
596
- } else {
597
- return `"${value}"`;
598
- }
599
- }
600
- }
601
-
602
- async function emitSendKeys(target, value) {
603
- return Promise.resolve(`self.driver.find_element(${await _location.default.emit(target)}).send_keys(${generateSendKeysInput(value)})`);
604
- }
605
-
606
- function emitSetSpeed() {
607
- return Promise.resolve('print("`set speed` is a no-op in code export, use `pause` instead")');
608
- }
609
-
610
- async function emitStore(value, varName) {
611
- return Promise.resolve(variableSetter(varName, `"${value}"`));
612
- }
613
-
614
- async function emitStoreAttribute(locator, varName) {
615
- const attributePos = locator.lastIndexOf('@');
616
- const elementLocator = locator.slice(0, attributePos);
617
- const attributeName = locator.slice(attributePos + 1);
618
- const commands = [{
619
- level: 0,
620
- statement: `attribute = self.driver.find_element(${await _location.default.emit(elementLocator)}).get_attribute("${attributeName}")`
621
- }, {
622
- level: 0,
623
- statement: `${variableSetter(varName, 'attribute')}`
624
- }];
625
- return Promise.resolve({
626
- commands
627
- });
628
- }
629
-
630
- async function emitStoreJson(json, varName) {
631
- return Promise.resolve(variableSetter(varName, `json.loads('${json}')`));
632
- }
633
-
634
- async function emitStoreText(locator, varName) {
635
- const result = `self.driver.find_element(${await _location.default.emit(locator)}).text`;
636
- return Promise.resolve(variableSetter(varName, result));
637
- }
638
-
639
- async function emitStoreTitle(_, varName) {
640
- return Promise.resolve(variableSetter(varName, 'self.driver.title'));
641
- }
642
-
643
- async function emitStoreValue(locator, varName) {
644
- const result = `self.driver.find_element(${await _location.default.emit(locator)}).get_attribute("value")`;
645
- return Promise.resolve(variableSetter(varName, result));
646
- }
647
-
648
- async function emitStoreWindowHandle(varName) {
649
- return Promise.resolve(variableSetter(varName, 'self.driver.current_window_handle'));
650
- }
651
-
652
- async function emitStoreXpathCount(locator, varName) {
653
- const result = `len(self.driver.find_elements(${await _location.default.emit(locator)}))`;
654
- return Promise.resolve(variableSetter(varName, result));
655
- }
656
-
657
- async function emitSubmit(_locator) {
658
- return Promise.resolve(`raise Exception("'submit' is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.")`);
659
- }
660
-
661
- async function emitType(target, value) {
662
- return Promise.resolve(`self.driver.find_element(${await _location.default.emit(target)}).send_keys(${generateSendKeysInput(value)})`);
663
- }
664
-
665
- async function emitUncheck(locator) {
666
- const commands = [{
667
- level: 0,
668
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
669
- }, {
670
- level: 0,
671
- statement: 'if element.is_selected: element.click()'
672
- }];
673
- return Promise.resolve({
674
- commands
675
- });
676
- }
677
-
678
- async function emitVerifyChecked(locator) {
679
- return Promise.resolve(`assert self.driver.find_element(${await _location.default.emit(locator)}).is_selected() is True`);
680
- }
681
-
682
- async function emitVerifyEditable(locator) {
683
- const commands = [{
684
- level: 0,
685
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
686
- }, {
687
- level: 0,
688
- statement: 'assert element.is_enabled() is True'
689
- }];
690
- return Promise.resolve({
691
- commands
692
- });
693
- }
694
-
695
- async function emitVerifyElementPresent(locator) {
696
- const commands = [{
697
- level: 0,
698
- statement: `elements = self.driver.find_elements(${await _location.default.emit(locator)})`
699
- }, {
700
- level: 0,
701
- statement: 'assert len(elements) > 0'
702
- }];
703
- return Promise.resolve({
704
- commands
705
- });
706
- }
707
-
708
- async function emitVerifyElementNotPresent(locator) {
709
- const commands = [{
710
- level: 0,
711
- statement: `elements = self.driver.find_elements(${await _location.default.emit(locator)})`
712
- }, {
713
- level: 0,
714
- statement: 'assert len(elements) == 0'
715
- }];
716
- return Promise.resolve({
717
- commands
718
- });
719
- }
720
-
721
- async function emitVerifyNotChecked(locator) {
722
- return Promise.resolve(`assert self.driver.find_element(${await _location.default.emit(locator)}).is_selected() is False`);
723
- }
724
-
725
- async function emitVerifyNotEditable(locator) {
726
- const commands = [{
727
- level: 0,
728
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
729
- }, {
730
- level: 0,
731
- statement: 'assert element.is_enabled() is False'
732
- }];
733
- return Promise.resolve({
734
- commands
735
- });
736
- }
737
-
738
- async function emitVerifyNotSelectedValue(locator, expectedValue) {
739
- const commands = [{
740
- level: 0,
741
- statement: `value = self.driver.find_element(${await _location.default.emit(locator)}).get_attribute("value")`
742
- }, {
743
- level: 0,
744
- statement: `assert value != "${_sideUtils.codeExport.emit.text(expectedValue)}"`
745
- }];
746
- return Promise.resolve({
747
- commands
748
- });
749
- }
750
-
751
- async function emitVerifyNotText(locator, text) {
752
- const commands = [{
753
- level: 0,
754
- statement: `text = self.driver.find_element(${await _location.default.emit(locator)}).text`
755
- }, {
756
- level: 0,
757
- statement: `assert text != "${_sideUtils.codeExport.emit.text(text)}"`
758
- }];
759
- return Promise.resolve({
760
- commands
761
- });
762
- }
763
-
764
- async function emitVerifySelectedLabel(locator, labelValue) {
765
- const commands = [{
766
- level: 0,
767
- statement: `element = self.driver.find_element(${await _location.default.emit(locator)})`
768
- }, {
769
- level: 0,
770
- statement: `locator = "option[@value='{}']".format(element.get_attribute("value"))`
771
- }, {
772
- level: 0,
773
- statement: 'selected_text = element.find_element(By.XPATH, locator).text'
774
- }, {
775
- level: 0,
776
- statement: `assert selected_text == "${labelValue}"`
777
- }];
778
- return Promise.resolve({
779
- commands
780
- });
781
- }
782
-
783
- async function emitVerifyText(locator, text) {
784
- const commands = [{
785
- level: 0,
786
- statement: `assert self.driver.find_element(${await _location.default.emit(locator)}).text == "${_sideUtils.codeExport.emit.text(text)}"`
787
- }];
788
- return Promise.resolve({
789
- commands
790
- });
791
- }
792
-
793
- async function emitVerifyValue(locator, value) {
794
- const commands = [{
795
- level: 0,
796
- statement: `value = self.driver.find_element(${await _location.default.emit(locator)}).get_attribute("value")`
797
- }, {
798
- level: 0,
799
- statement: `assert value == "${value}"`
800
- }];
801
- return Promise.resolve({
802
- commands
803
- });
804
- }
805
-
806
- async function emitVerifyTitle(title) {
807
- return Promise.resolve(`assert self.driver.title == "${title}"`);
808
- }
809
-
810
- async function emitWaitForElementEditable(locator, timeout) {
811
- const commands = [{
812
- level: 0,
813
- statement: `WebDriverWait(self.driver, ${timeout}).until(expected_conditions.element_to_be_clickable((${await _location.default.emit(locator)})))`
814
- }];
815
- return Promise.resolve({
816
- commands
817
- });
818
- }
819
-
820
- function skip() {
821
- return Promise.resolve(undefined);
822
- }
823
-
824
- async function emitWaitForElementPresent(locator, timeout) {
825
- const commands = [{
826
- level: 0,
827
- statement: `WebDriverWait(self.driver, ${timeout}).until(expected_conditions.presence_of_element_located((${await _location.default.emit(locator)})))`
828
- }];
829
- return Promise.resolve({
830
- commands
831
- });
832
- }
833
-
834
- async function emitWaitForElementVisible(locator, timeout) {
835
- const commands = [{
836
- level: 0,
837
- statement: `WebDriverWait(self.driver, ${timeout}).until(expected_conditions.visibility_of_element_located((${await _location.default.emit(locator)})))`
838
- }];
839
- return Promise.resolve({
840
- commands
841
- });
842
- }
843
-
844
- async function emitWaitForElementNotEditable(locator, timeout) {
845
- const commands = [{
846
- level: 0,
847
- statement: `WebDriverWait(self.driver, ${timeout}).until_not(expected_conditions.element_to_be_clickable((${await _location.default.emit(locator)})))`
848
- }];
849
- return Promise.resolve({
850
- commands
851
- });
852
- }
853
-
854
- async function emitWaitForElementNotPresent(locator, timeout) {
855
- const commands = [{
856
- level: 0,
857
- statement: `WebDriverWait(self.driver, ${timeout}).until(expected_conditions.invisibility_of_element_located((${await _location.default.emit(locator)})))`
858
- }];
859
- return Promise.resolve({
860
- commands
861
- });
862
- }
863
-
864
- async function emitWaitForElementNotVisible(locator, timeout) {
865
- const commands = [{
866
- level: 0,
867
- statement: `WebDriverWait(self.driver, ${timeout}).until(expected_conditions.invisibility_of_element_located((${await _location.default.emit(locator)})))`
868
- }];
869
- return Promise.resolve({
870
- commands
871
- });
872
- }
873
-
874
- var _default = {
875
- canEmit,
876
- emit,
877
- register,
878
- extras: {
879
- emitWaitForWindow
880
- }
881
- };
882
- exports.default = _default;