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