@seleniumhq/code-export-csharp-commons 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/__test__/src/__snapshots__/command.spec.js.snap +8 -1
- package/__test__/src/command.spec.js +9 -1
- package/package.json +2 -2
- package/src/command.js +24 -2
- package/src/location.js +1 -1
- package/src/selection.js +1 -1
- package/dist/command.js +0 -1114
- package/dist/index.js +0 -34
- package/dist/location.js +0 -68
- package/dist/selection.js +0 -57
- package/yarn-error.log +0 -2151
package/dist/command.js
DELETED
|
@@ -1,1114 +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: emitVerifySelectedValue,
|
|
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: emitVerifySelectedValue,
|
|
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 `vars["${varName}"].ToString()`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function variableSetter(varName, value) {
|
|
159
|
-
return varName ? `vars["${varName}"] = ${value};` : '';
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
function emitWaitForWindow() {
|
|
163
|
-
const generateMethodDeclaration = name => {
|
|
164
|
-
return `public string ${name}(int timeout) {`;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const commands = [{
|
|
168
|
-
level: 0,
|
|
169
|
-
statement: 'try {'
|
|
170
|
-
}, {
|
|
171
|
-
level: 1,
|
|
172
|
-
statement: 'Thread.Sleep(timeout);'
|
|
173
|
-
}, {
|
|
174
|
-
level: 0,
|
|
175
|
-
statement: '} catch(Exception e) {'
|
|
176
|
-
}, {
|
|
177
|
-
level: 1,
|
|
178
|
-
statement: 'Console.WriteLine("{0} Exception caught.", e);'
|
|
179
|
-
}, {
|
|
180
|
-
level: 0,
|
|
181
|
-
statement: '}'
|
|
182
|
-
}, {
|
|
183
|
-
level: 0,
|
|
184
|
-
statement: 'var whNow = ((IReadOnlyCollection<object>)driver.WindowHandles).ToList();'
|
|
185
|
-
}, {
|
|
186
|
-
level: 0,
|
|
187
|
-
statement: 'var whThen = ((IReadOnlyCollection<object>)vars["WindowHandles"]).ToList();'
|
|
188
|
-
}, {
|
|
189
|
-
level: 0,
|
|
190
|
-
statement: 'if (whNow.Count > whThen.Count) {'
|
|
191
|
-
}, {
|
|
192
|
-
level: 1,
|
|
193
|
-
statement: 'return whNow.Except(whThen).First().ToString();'
|
|
194
|
-
}, {
|
|
195
|
-
level: 0,
|
|
196
|
-
statement: '} else {'
|
|
197
|
-
}, {
|
|
198
|
-
level: 1,
|
|
199
|
-
statement: 'return whNow.First().ToString();'
|
|
200
|
-
}, {
|
|
201
|
-
level: 0,
|
|
202
|
-
statement: '}'
|
|
203
|
-
}];
|
|
204
|
-
return Promise.resolve({
|
|
205
|
-
name: 'waitForWindow',
|
|
206
|
-
commands,
|
|
207
|
-
generateMethodDeclaration
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
async function emitNewWindowHandling(command, emittedCommand) {
|
|
212
|
-
return Promise.resolve(`vars["WindowHandles"] = driver.WindowHandles;\n${await emittedCommand}\nvars["${command.windowHandleName}"] = waitForWindow(${command.windowTimeout});`);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function emitAssert(varName, value) {
|
|
216
|
-
const _value = value === 'true' || value === 'false' ? _sideUtils.codeExport.parsers.capitalize(value) : value;
|
|
217
|
-
|
|
218
|
-
return Promise.resolve(`Assert.That(vars["${varName}"].ToString(), Is.EqualTo("${_value}"));`);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
function emitAssertAlert(alertText) {
|
|
222
|
-
return Promise.resolve(`Assert.That(driver.SwitchTo().Alert().Text, Is.EqualTo("${alertText}"));`);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function emitAnswerOnNextPrompt(textToSend) {
|
|
226
|
-
const commands = [{
|
|
227
|
-
level: 0,
|
|
228
|
-
statement: '{'
|
|
229
|
-
}, {
|
|
230
|
-
level: 1,
|
|
231
|
-
statement: 'var Alert = driver.SwitchTo().Alert();'
|
|
232
|
-
}, {
|
|
233
|
-
level: 1,
|
|
234
|
-
statement: `Alert.SendKeys("${textToSend}")`
|
|
235
|
-
}, {
|
|
236
|
-
level: 1,
|
|
237
|
-
statement: 'Alert.Accept();'
|
|
238
|
-
}, {
|
|
239
|
-
level: 0,
|
|
240
|
-
statement: '}'
|
|
241
|
-
}];
|
|
242
|
-
return Promise.resolve({
|
|
243
|
-
commands
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
async function emitCheck(locator) {
|
|
248
|
-
const commands = [{
|
|
249
|
-
level: 0,
|
|
250
|
-
statement: '{'
|
|
251
|
-
}, {
|
|
252
|
-
level: 1,
|
|
253
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
254
|
-
}, {
|
|
255
|
-
level: 1,
|
|
256
|
-
statement: 'if (!element.Selected) {'
|
|
257
|
-
}, {
|
|
258
|
-
level: 2,
|
|
259
|
-
statement: 'element.Click();'
|
|
260
|
-
}, {
|
|
261
|
-
level: 1,
|
|
262
|
-
statement: '}'
|
|
263
|
-
}, {
|
|
264
|
-
level: 0,
|
|
265
|
-
statement: '}'
|
|
266
|
-
}];
|
|
267
|
-
return Promise.resolve({
|
|
268
|
-
commands
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function emitChooseCancelOnNextConfirmation() {
|
|
273
|
-
return Promise.resolve(`driver.SwitchTo().Alert().Dismiss();`);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
function emitChooseOkOnNextConfirmation() {
|
|
277
|
-
return Promise.resolve(`driver.SwitchTo().Alert().Accept();`);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
async function emitClick(target) {
|
|
281
|
-
return Promise.resolve(`driver.FindElement(${await _location.default.emit(target)}).Click();`);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
async function emitClose() {
|
|
285
|
-
return Promise.resolve(`driver.Close();`);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function generateExpressionScript(script) {
|
|
289
|
-
const scriptString = script.script.replace(/"/g, "'");
|
|
290
|
-
return `(Boolean) js.ExecuteScript("return (${scriptString})"${generateScriptArguments(script)})`;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function emitControlFlowDo() {
|
|
294
|
-
return Promise.resolve({
|
|
295
|
-
commands: [{
|
|
296
|
-
level: 0,
|
|
297
|
-
statement: 'do {'
|
|
298
|
-
}],
|
|
299
|
-
endingLevelAdjustment: 1
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function emitControlFlowElse() {
|
|
304
|
-
return Promise.resolve({
|
|
305
|
-
commands: [{
|
|
306
|
-
level: 0,
|
|
307
|
-
statement: '} else {'
|
|
308
|
-
}],
|
|
309
|
-
startingLevelAdjustment: -1,
|
|
310
|
-
endingLevelAdjustment: +1
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function emitControlFlowElseIf(script) {
|
|
315
|
-
return Promise.resolve({
|
|
316
|
-
commands: [{
|
|
317
|
-
level: 0,
|
|
318
|
-
statement: `} else if (${generateExpressionScript(script)}) {`
|
|
319
|
-
}],
|
|
320
|
-
startingLevelAdjustment: -1,
|
|
321
|
-
endingLevelAdjustment: +1
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
function emitControlFlowEnd() {
|
|
326
|
-
return Promise.resolve({
|
|
327
|
-
commands: [{
|
|
328
|
-
level: 0,
|
|
329
|
-
statement: `}`
|
|
330
|
-
}],
|
|
331
|
-
startingLevelAdjustment: -1
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function emitControlFlowIf(script) {
|
|
336
|
-
return Promise.resolve({
|
|
337
|
-
commands: [{
|
|
338
|
-
level: 0,
|
|
339
|
-
statement: `if (${generateExpressionScript(script)}) {`
|
|
340
|
-
}],
|
|
341
|
-
endingLevelAdjustment: 1
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
function emitControlFlowForEach(collectionVarName, iteratorVarName) {
|
|
346
|
-
return Promise.resolve({
|
|
347
|
-
commands: [{
|
|
348
|
-
level: 0,
|
|
349
|
-
statement: `var ${collectionVarName}Enum = ((IReadOnlyCollection<object>)vars["${collectionVarName}"]).ToList().GetEnumerator();`
|
|
350
|
-
}, {
|
|
351
|
-
level: 0,
|
|
352
|
-
statement: `while (${collectionVarName}Enum.MoveNext())`
|
|
353
|
-
}, {
|
|
354
|
-
level: 0,
|
|
355
|
-
statement: `{`
|
|
356
|
-
}, {
|
|
357
|
-
level: 1,
|
|
358
|
-
statement: `vars["${iteratorVarName}"] = ${collectionVarName}Enum.Current;`
|
|
359
|
-
}]
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
function emitControlFlowRepeatIf(script) {
|
|
364
|
-
return Promise.resolve({
|
|
365
|
-
commands: [{
|
|
366
|
-
level: 0,
|
|
367
|
-
statement: `} while (${generateExpressionScript(script)});`
|
|
368
|
-
}],
|
|
369
|
-
startingLevelAdjustment: -1
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function emitControlFlowTimes(target) {
|
|
374
|
-
const commands = [{
|
|
375
|
-
level: 0,
|
|
376
|
-
statement: `var times = ${target};`
|
|
377
|
-
}, {
|
|
378
|
-
level: 0,
|
|
379
|
-
statement: 'for(int i = 0; i < times; i++) {'
|
|
380
|
-
}];
|
|
381
|
-
return Promise.resolve({
|
|
382
|
-
commands,
|
|
383
|
-
endingLevelAdjustment: 1
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function emitControlFlowWhile(script) {
|
|
388
|
-
return Promise.resolve({
|
|
389
|
-
commands: [{
|
|
390
|
-
level: 0,
|
|
391
|
-
statement: `while (${generateExpressionScript(script)}) {`
|
|
392
|
-
}],
|
|
393
|
-
endingLevelAdjustment: 1
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
async function emitDoubleClick(target) {
|
|
398
|
-
const commands = [{
|
|
399
|
-
level: 0,
|
|
400
|
-
statement: '{'
|
|
401
|
-
}, {
|
|
402
|
-
level: 1,
|
|
403
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(target)});`
|
|
404
|
-
}, {
|
|
405
|
-
level: 1,
|
|
406
|
-
statement: 'Actions builder = new Actions(driver);'
|
|
407
|
-
}, {
|
|
408
|
-
level: 1,
|
|
409
|
-
statement: 'builder.DoubleClick(element).Perform();'
|
|
410
|
-
}, {
|
|
411
|
-
level: 0,
|
|
412
|
-
statement: '}'
|
|
413
|
-
}];
|
|
414
|
-
return Promise.resolve({
|
|
415
|
-
commands
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
async function emitDragAndDrop(dragged, dropped) {
|
|
420
|
-
const commands = [{
|
|
421
|
-
level: 0,
|
|
422
|
-
statement: '{'
|
|
423
|
-
}, {
|
|
424
|
-
level: 1,
|
|
425
|
-
statement: `var dragged = driver.FindElement(${await _location.default.emit(dragged)});`
|
|
426
|
-
}, {
|
|
427
|
-
level: 1,
|
|
428
|
-
statement: `var dropped = driver.FindElement(${await _location.default.emit(dropped)});`
|
|
429
|
-
}, {
|
|
430
|
-
level: 1,
|
|
431
|
-
statement: 'Actions builder = new Actions(driver);'
|
|
432
|
-
}, {
|
|
433
|
-
level: 1,
|
|
434
|
-
statement: 'builder.DragAndDrop(dragged, dropped).Perform();'
|
|
435
|
-
}, {
|
|
436
|
-
level: 0,
|
|
437
|
-
statement: '}'
|
|
438
|
-
}];
|
|
439
|
-
return Promise.resolve({
|
|
440
|
-
commands
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
async function emitEcho(message) {
|
|
445
|
-
const _message = message.startsWith('vars[') ? message : `"${message}"`;
|
|
446
|
-
|
|
447
|
-
return Promise.resolve(`Console.WriteLine(${_message});`);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
async function emitEditContent(locator, content) {
|
|
451
|
-
const commands = [{
|
|
452
|
-
level: 0,
|
|
453
|
-
statement: '{'
|
|
454
|
-
}, {
|
|
455
|
-
level: 1,
|
|
456
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
457
|
-
}, {
|
|
458
|
-
level: 1,
|
|
459
|
-
statement: `js.ExecuteScript("if(arguments[0].contentEditable === 'true') {arguments[0].innerText = '${content}'}", element);`
|
|
460
|
-
}, {
|
|
461
|
-
level: 0,
|
|
462
|
-
statement: '}'
|
|
463
|
-
}];
|
|
464
|
-
return Promise.resolve({
|
|
465
|
-
commands
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
async function emitExecuteScript(script, varName) {
|
|
470
|
-
const result = `js.ExecuteScript("${script.script}"${generateScriptArguments(script)})`;
|
|
471
|
-
return Promise.resolve(variableSetter(varName, result));
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
async function emitExecuteAsyncScript(script, varName) {
|
|
475
|
-
const result = `js.executeAsyncScript("var callback = arguments[arguments.length - 1];${script.script}.then(callback).catch(callback);${generateScriptArguments(script)}")`;
|
|
476
|
-
return Promise.resolve(variableSetter(varName, result));
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
function generateScriptArguments(script) {
|
|
480
|
-
return `${script.argv.length ? ', ' : ''}${script.argv.map(varName => `vars["${varName}"]`).join(',')}`;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
async function emitMouseDown(locator) {
|
|
484
|
-
const commands = [{
|
|
485
|
-
level: 0,
|
|
486
|
-
statement: '{'
|
|
487
|
-
}, {
|
|
488
|
-
level: 1,
|
|
489
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
490
|
-
}, {
|
|
491
|
-
level: 1,
|
|
492
|
-
statement: 'Actions builder = new Actions(driver);'
|
|
493
|
-
}, {
|
|
494
|
-
level: 1,
|
|
495
|
-
statement: 'builder.MoveToElement(element).ClickAndHold().Perform();'
|
|
496
|
-
}, {
|
|
497
|
-
level: 0,
|
|
498
|
-
statement: '}'
|
|
499
|
-
}];
|
|
500
|
-
return Promise.resolve({
|
|
501
|
-
commands
|
|
502
|
-
});
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
async function emitMouseMove(locator) {
|
|
506
|
-
const commands = [{
|
|
507
|
-
level: 0,
|
|
508
|
-
statement: '{'
|
|
509
|
-
}, {
|
|
510
|
-
level: 1,
|
|
511
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
512
|
-
}, {
|
|
513
|
-
level: 1,
|
|
514
|
-
statement: 'Actions builder = new Actions(driver);'
|
|
515
|
-
}, {
|
|
516
|
-
level: 1,
|
|
517
|
-
statement: 'builder.MoveToElement(element).Perform();'
|
|
518
|
-
}, {
|
|
519
|
-
level: 0,
|
|
520
|
-
statement: '}'
|
|
521
|
-
}];
|
|
522
|
-
return Promise.resolve({
|
|
523
|
-
commands
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
async function emitMouseOut() {
|
|
528
|
-
const commands = [{
|
|
529
|
-
level: 0,
|
|
530
|
-
statement: '{'
|
|
531
|
-
}, {
|
|
532
|
-
level: 1,
|
|
533
|
-
statement: `var element = driver.FindElement(By.tagName("body"));`
|
|
534
|
-
}, {
|
|
535
|
-
level: 1,
|
|
536
|
-
statement: 'Actions builder = new Actions(driver);'
|
|
537
|
-
}, {
|
|
538
|
-
level: 1,
|
|
539
|
-
statement: 'builder.MoveToElement(element, 0, 0).Perform();'
|
|
540
|
-
}, {
|
|
541
|
-
level: 0,
|
|
542
|
-
statement: '}'
|
|
543
|
-
}];
|
|
544
|
-
return Promise.resolve({
|
|
545
|
-
commands
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
async function emitMouseUp(locator) {
|
|
550
|
-
const commands = [{
|
|
551
|
-
level: 0,
|
|
552
|
-
statement: '{'
|
|
553
|
-
}, {
|
|
554
|
-
level: 1,
|
|
555
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
556
|
-
}, {
|
|
557
|
-
level: 1,
|
|
558
|
-
statement: 'Actions builder = new Actions(driver);'
|
|
559
|
-
}, {
|
|
560
|
-
level: 1,
|
|
561
|
-
statement: 'builder.MoveToElement(element).Release().Perform();'
|
|
562
|
-
}, {
|
|
563
|
-
level: 0,
|
|
564
|
-
statement: '}'
|
|
565
|
-
}];
|
|
566
|
-
return Promise.resolve({
|
|
567
|
-
commands
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
function emitOpen(target) {
|
|
572
|
-
const url = /^(file|http|https):\/\//.test(target) ? `"${target}"` : `"${global.baseUrl}${target}"`;
|
|
573
|
-
return Promise.resolve(`driver.Navigate().GoToUrl(${url});`);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
async function emitPause(time) {
|
|
577
|
-
const commands = [{
|
|
578
|
-
level: 0,
|
|
579
|
-
statement: 'try {'
|
|
580
|
-
}, {
|
|
581
|
-
level: 1,
|
|
582
|
-
statement: `Thread.Sleep(${time});`
|
|
583
|
-
}, {
|
|
584
|
-
level: 0,
|
|
585
|
-
statement: '} catch {'
|
|
586
|
-
}, {
|
|
587
|
-
level: 1,
|
|
588
|
-
statement: 'Console.WriteLine("{0} Exception caught.", e);'
|
|
589
|
-
}, {
|
|
590
|
-
level: 0,
|
|
591
|
-
statement: '}'
|
|
592
|
-
}];
|
|
593
|
-
return Promise.resolve({
|
|
594
|
-
commands
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
async function emitRun(testName) {
|
|
599
|
-
return Promise.resolve(`${_sideUtils.codeExport.parsers.sanitizeName(testName)}();`);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
async function emitRunScript(script) {
|
|
603
|
-
return Promise.resolve(`js.ExecuteScript("${script.script}${generateScriptArguments(script)}");`);
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
async function emitSetWindowSize(size) {
|
|
607
|
-
const [width, height] = size.split('x');
|
|
608
|
-
return Promise.resolve(`driver.Manage().Window.Size = new System.Drawing.Size(${width}, ${height});`);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
async function emitSelect(selectElement, option) {
|
|
612
|
-
const commands = [{
|
|
613
|
-
level: 0,
|
|
614
|
-
statement: '{'
|
|
615
|
-
}, {
|
|
616
|
-
level: 1,
|
|
617
|
-
statement: `var dropdown = driver.FindElement(${await _location.default.emit(selectElement)});`
|
|
618
|
-
}, {
|
|
619
|
-
level: 1,
|
|
620
|
-
statement: `dropdown.FindElement(${await _selection.default.emit(option)}).Click();`
|
|
621
|
-
}, {
|
|
622
|
-
level: 0,
|
|
623
|
-
statement: '}'
|
|
624
|
-
}];
|
|
625
|
-
return Promise.resolve({
|
|
626
|
-
commands
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
async function emitSelectFrame(frameLocation) {
|
|
631
|
-
if (frameLocation === 'relative=top' || frameLocation === 'relative=parent') {
|
|
632
|
-
return Promise.resolve('driver.SwitchTo().DefaultContent();');
|
|
633
|
-
} else if (/^index=/.test(frameLocation)) {
|
|
634
|
-
return Promise.resolve(`driver.SwitchTo().Frame(${Math.floor(frameLocation.split('index=')[1])});`);
|
|
635
|
-
} else {
|
|
636
|
-
return Promise.resolve({
|
|
637
|
-
commands: [{
|
|
638
|
-
level: 0,
|
|
639
|
-
statement: '{'
|
|
640
|
-
}, {
|
|
641
|
-
level: 1,
|
|
642
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(frameLocation)});`
|
|
643
|
-
}, {
|
|
644
|
-
level: 1,
|
|
645
|
-
statement: 'driver.SwitchTo().Frame(element);'
|
|
646
|
-
}, {
|
|
647
|
-
level: 0,
|
|
648
|
-
statement: '}'
|
|
649
|
-
}]
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
async function emitSelectWindow(windowLocation) {
|
|
655
|
-
if (/^handle=/.test(windowLocation)) {
|
|
656
|
-
return Promise.resolve(`driver.SwitchTo().Window(${windowLocation.split('handle=')[1]});`);
|
|
657
|
-
} else if (/^name=/.test(windowLocation)) {
|
|
658
|
-
return Promise.resolve(`driver.SwitchTo().Window("${windowLocation.split('name=')[1]}");`);
|
|
659
|
-
} else if (/^win_ser_/.test(windowLocation)) {
|
|
660
|
-
if (windowLocation === 'win_ser_local') {
|
|
661
|
-
return Promise.resolve({
|
|
662
|
-
commands: [{
|
|
663
|
-
level: 0,
|
|
664
|
-
statement: '{'
|
|
665
|
-
}, {
|
|
666
|
-
level: 1,
|
|
667
|
-
statement: 'ArrayList<string> handles = new ArrayList<string>(driver.WindowHandles());'
|
|
668
|
-
}, {
|
|
669
|
-
level: 1,
|
|
670
|
-
statement: 'driver.SwitchTo().Window(handles[0]);'
|
|
671
|
-
}, {
|
|
672
|
-
level: 0,
|
|
673
|
-
statement: '}'
|
|
674
|
-
}]
|
|
675
|
-
});
|
|
676
|
-
} else {
|
|
677
|
-
const index = parseInt(windowLocation.substr('win_ser_'.length));
|
|
678
|
-
return Promise.resolve({
|
|
679
|
-
commands: [{
|
|
680
|
-
level: 0,
|
|
681
|
-
statement: '{'
|
|
682
|
-
}, {
|
|
683
|
-
level: 1,
|
|
684
|
-
statement: 'ArrayList<string> handles = new ArrayList<string>(driver.WindowHandles);'
|
|
685
|
-
}, {
|
|
686
|
-
level: 1,
|
|
687
|
-
statement: `driver.SwitchTo().Window(handles[${index}]);`
|
|
688
|
-
}, {
|
|
689
|
-
level: 0,
|
|
690
|
-
statement: '}'
|
|
691
|
-
}]
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
} else {
|
|
695
|
-
return Promise.reject(new Error('Can only emit `select window` using handles'));
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
function generateSendKeysInput(value) {
|
|
700
|
-
if (typeof value === 'object') {
|
|
701
|
-
return value.map(s => {
|
|
702
|
-
if (s.startsWith('vars[')) {
|
|
703
|
-
return s;
|
|
704
|
-
} else if (s.startsWith('Key[')) {
|
|
705
|
-
const key = s.match(/\['(.*)'\]/)[1];
|
|
706
|
-
return `Keys.${_sideUtils.codeExport.parsers.capitalize(key.toLowerCase())}`;
|
|
707
|
-
} else {
|
|
708
|
-
return `"${s}"`;
|
|
709
|
-
}
|
|
710
|
-
}).join(' + ');
|
|
711
|
-
} else {
|
|
712
|
-
if (value.startsWith('vars[')) {
|
|
713
|
-
return value;
|
|
714
|
-
} else {
|
|
715
|
-
return `"${value}"`;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
async function emitSendKeys(target, value) {
|
|
721
|
-
return Promise.resolve(`driver.FindElement(${await _location.default.emit(target)}).SendKeys(${generateSendKeysInput(value)});`);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
function emitSetSpeed() {
|
|
725
|
-
return Promise.resolve(`Console.WriteLine("\`set speed\` is a no-op in code export, use \`pause\` instead");`);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
async function emitStore(value, varName) {
|
|
729
|
-
return Promise.resolve(variableSetter(varName, `"${value}"`));
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
async function emitStoreAttribute(locator, varName) {
|
|
733
|
-
const attributePos = locator.lastIndexOf('@');
|
|
734
|
-
const elementLocator = locator.slice(0, attributePos);
|
|
735
|
-
const attributeName = locator.slice(attributePos + 1);
|
|
736
|
-
const commands = [{
|
|
737
|
-
level: 0,
|
|
738
|
-
statement: '{'
|
|
739
|
-
}, {
|
|
740
|
-
level: 1,
|
|
741
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(elementLocator)});`
|
|
742
|
-
}, {
|
|
743
|
-
level: 1,
|
|
744
|
-
statement: `string attribute = element.GetAttribute("${attributeName}");`
|
|
745
|
-
}, {
|
|
746
|
-
level: 1,
|
|
747
|
-
statement: `${variableSetter(varName, 'attribute')}`
|
|
748
|
-
}, {
|
|
749
|
-
level: 0,
|
|
750
|
-
statement: '}'
|
|
751
|
-
}];
|
|
752
|
-
return Promise.resolve({
|
|
753
|
-
commands
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
async function emitStoreJson(_json, _varName) {
|
|
758
|
-
return Promise.resolve('throw new System.Exception("The `storeJson` command is not yet implemented for this language.");');
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
async function emitStoreText(locator, varName) {
|
|
762
|
-
const result = `driver.FindElement(${await _location.default.emit(locator)}).Text`;
|
|
763
|
-
return Promise.resolve(variableSetter(varName, result));
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
async function emitStoreTitle(_, varName) {
|
|
767
|
-
return Promise.resolve(variableSetter(varName, 'driver.Title'));
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
async function emitStoreValue(locator, varName) {
|
|
771
|
-
const result = `driver.FindElement(${await _location.default.emit(locator)}).GetAttribute("value")`;
|
|
772
|
-
return Promise.resolve(variableSetter(varName, result));
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
async function emitStoreWindowHandle(varName) {
|
|
776
|
-
return Promise.resolve(variableSetter(varName, 'driver.CurrentWindowHandle'));
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
async function emitStoreXpathCount(locator, varName) {
|
|
780
|
-
const result = `driver.FindElements(${await _location.default.emit(locator)}).Count`;
|
|
781
|
-
return Promise.resolve(variableSetter(varName, result));
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
async function emitSubmit(_locator) {
|
|
785
|
-
return Promise.resolve(`throw new System.Exception("\`submit\` is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.");`);
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
async function emitType(target, value) {
|
|
789
|
-
return Promise.resolve(`driver.FindElement(${await _location.default.emit(target)}).SendKeys(${generateSendKeysInput(value)});`);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
async function emitUncheck(locator) {
|
|
793
|
-
const commands = [{
|
|
794
|
-
level: 0,
|
|
795
|
-
statement: '{'
|
|
796
|
-
}, {
|
|
797
|
-
level: 1,
|
|
798
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
799
|
-
}, {
|
|
800
|
-
level: 1,
|
|
801
|
-
statement: 'if (element.Selected) {'
|
|
802
|
-
}, {
|
|
803
|
-
level: 2,
|
|
804
|
-
statement: 'element.Click();'
|
|
805
|
-
}, {
|
|
806
|
-
level: 1,
|
|
807
|
-
statement: '}'
|
|
808
|
-
}, {
|
|
809
|
-
level: 0,
|
|
810
|
-
statement: '}'
|
|
811
|
-
}];
|
|
812
|
-
return Promise.resolve({
|
|
813
|
-
commands
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
async function emitVerifyChecked(locator) {
|
|
818
|
-
return Promise.resolve(`Assert.True(driver.FindElement(${await _location.default.emit(locator)}).Selected);`);
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
async function emitVerifyEditable(locator) {
|
|
822
|
-
const commands = [{
|
|
823
|
-
level: 0,
|
|
824
|
-
statement: '{'
|
|
825
|
-
}, {
|
|
826
|
-
level: 1,
|
|
827
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
828
|
-
}, {
|
|
829
|
-
level: 1,
|
|
830
|
-
statement: 'Boolean isEditable = element.Enabled && element.GetAttribute("readonly") == null;'
|
|
831
|
-
}, {
|
|
832
|
-
level: 1,
|
|
833
|
-
statement: 'Assert.True(isEditable);'
|
|
834
|
-
}, {
|
|
835
|
-
level: 0,
|
|
836
|
-
statement: '}'
|
|
837
|
-
}];
|
|
838
|
-
return Promise.resolve({
|
|
839
|
-
commands
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
async function emitVerifyElementPresent(locator) {
|
|
844
|
-
const commands = [{
|
|
845
|
-
level: 0,
|
|
846
|
-
statement: `var elements = driver.FindElements(${await _location.default.emit(locator)});`
|
|
847
|
-
}, {
|
|
848
|
-
level: 0,
|
|
849
|
-
statement: 'Assert.True(elements.Count > 0);'
|
|
850
|
-
}];
|
|
851
|
-
return Promise.resolve({
|
|
852
|
-
commands
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
async function emitVerifyElementNotPresent(locator) {
|
|
857
|
-
const commands = [{
|
|
858
|
-
level: 0,
|
|
859
|
-
statement: '{'
|
|
860
|
-
}, {
|
|
861
|
-
level: 1,
|
|
862
|
-
statement: `var elements = driver.FindElements(${await _location.default.emit(locator)});`
|
|
863
|
-
}, {
|
|
864
|
-
level: 1,
|
|
865
|
-
statement: 'Assert.True(elements.Count == 0);'
|
|
866
|
-
}, {
|
|
867
|
-
level: 0,
|
|
868
|
-
statement: '}'
|
|
869
|
-
}];
|
|
870
|
-
return Promise.resolve({
|
|
871
|
-
commands
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
async function emitVerifyNotChecked(locator) {
|
|
876
|
-
return Promise.resolve(`Assert.False(driver.FindElement(${await _location.default.emit(locator)}).Selected);`);
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
async function emitVerifyNotEditable(locator) {
|
|
880
|
-
const commands = [{
|
|
881
|
-
level: 0,
|
|
882
|
-
statement: '{'
|
|
883
|
-
}, {
|
|
884
|
-
level: 1,
|
|
885
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
886
|
-
}, {
|
|
887
|
-
level: 1,
|
|
888
|
-
statement: 'Boolean isEditable = element.Enabled && element.GetAttribute("readonly") == null;'
|
|
889
|
-
}, {
|
|
890
|
-
level: 1,
|
|
891
|
-
statement: 'Assert.False(isEditable);'
|
|
892
|
-
}, {
|
|
893
|
-
level: 0,
|
|
894
|
-
statement: '}'
|
|
895
|
-
}];
|
|
896
|
-
return Promise.resolve({
|
|
897
|
-
commands
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
async function emitVerifyNotSelectedValue(locator, expectedValue) {
|
|
902
|
-
const commands = [{
|
|
903
|
-
level: 0,
|
|
904
|
-
statement: '{'
|
|
905
|
-
}, {
|
|
906
|
-
level: 1,
|
|
907
|
-
statement: `string value = driver.FindElement(${await _location.default.emit(locator)}).GetAttribute("value");`
|
|
908
|
-
}, {
|
|
909
|
-
level: 1,
|
|
910
|
-
statement: `Assert.That(value, Is.Not.EqualTo("${_sideUtils.codeExport.emit.text(expectedValue)}"));`
|
|
911
|
-
}, {
|
|
912
|
-
level: 0,
|
|
913
|
-
statement: '}'
|
|
914
|
-
}];
|
|
915
|
-
return Promise.resolve({
|
|
916
|
-
commands
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
async function emitVerifyNotText(locator, text) {
|
|
921
|
-
const result = `driver.FindElement(${await _location.default.emit(locator)}).Text`;
|
|
922
|
-
return Promise.resolve(`Assert.That(${result}, Is.Not.EqualTo("${_sideUtils.codeExport.emit.text(text)}"));`);
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
async function emitVerifySelectedLabel(locator, labelValue) {
|
|
926
|
-
const commands = [{
|
|
927
|
-
level: 0,
|
|
928
|
-
statement: '{'
|
|
929
|
-
}, {
|
|
930
|
-
level: 1,
|
|
931
|
-
statement: `var element = driver.FindElement(${await _location.default.emit(locator)});`
|
|
932
|
-
}, {
|
|
933
|
-
level: 1,
|
|
934
|
-
statement: 'string value = element.GetAttribute("value");'
|
|
935
|
-
}, {
|
|
936
|
-
level: 1,
|
|
937
|
-
statement: `string locator = string.Format("option[@value='%s']", value);`
|
|
938
|
-
}, {
|
|
939
|
-
level: 1,
|
|
940
|
-
statement: 'string selectedText = element.FindElement(By.XPath(locator)).Text;'
|
|
941
|
-
}, {
|
|
942
|
-
level: 1,
|
|
943
|
-
statement: `Assert.That(selectedText, Is.EqualTo("${labelValue}"));`
|
|
944
|
-
}, {
|
|
945
|
-
level: 0,
|
|
946
|
-
statement: '}'
|
|
947
|
-
}];
|
|
948
|
-
return Promise.resolve({
|
|
949
|
-
commands
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
async function emitVerifySelectedValue(locator, value) {
|
|
954
|
-
return emitVerifyValue(locator, value);
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
async function emitVerifyText(locator, text) {
|
|
958
|
-
return Promise.resolve(`Assert.That(driver.FindElement(${await _location.default.emit(locator)}).Text, Is.EqualTo("${_sideUtils.codeExport.emit.text(text)}"));`);
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
async function emitVerifyValue(locator, value) {
|
|
962
|
-
const commands = [{
|
|
963
|
-
level: 0,
|
|
964
|
-
statement: '{'
|
|
965
|
-
}, {
|
|
966
|
-
level: 1,
|
|
967
|
-
statement: `string value = driver.FindElement(${await _location.default.emit(locator)}).GetAttribute("value");`
|
|
968
|
-
}, {
|
|
969
|
-
level: 1,
|
|
970
|
-
statement: `Assert.That(value, Is.EqualTo("${value}"));`
|
|
971
|
-
}, {
|
|
972
|
-
level: 0,
|
|
973
|
-
statement: '}'
|
|
974
|
-
}];
|
|
975
|
-
return Promise.resolve({
|
|
976
|
-
commands
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
async function emitVerifyTitle(title) {
|
|
981
|
-
return Promise.resolve(`Assert.That(driver.Title, Is.EqualTo("${title}"));`);
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
async function emitWaitForElementEditable(locator, timeout) {
|
|
985
|
-
const commands = [{
|
|
986
|
-
level: 0,
|
|
987
|
-
statement: '{'
|
|
988
|
-
}, {
|
|
989
|
-
level: 1,
|
|
990
|
-
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`
|
|
991
|
-
}, {
|
|
992
|
-
level: 1,
|
|
993
|
-
statement: `wait.Until(driver => driver.FindElement(${await _location.default.emit(locator)}).Enabled);`
|
|
994
|
-
}, {
|
|
995
|
-
level: 0,
|
|
996
|
-
statement: '}'
|
|
997
|
-
}];
|
|
998
|
-
return Promise.resolve({
|
|
999
|
-
commands
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
function skip() {
|
|
1004
|
-
return Promise.resolve('');
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
async function emitWaitForElementPresent(locator, timeout) {
|
|
1008
|
-
const commands = [{
|
|
1009
|
-
level: 0,
|
|
1010
|
-
statement: '{'
|
|
1011
|
-
}, {
|
|
1012
|
-
level: 1,
|
|
1013
|
-
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`
|
|
1014
|
-
}, {
|
|
1015
|
-
level: 1,
|
|
1016
|
-
statement: `wait.Until(driver => driver.FindElements(${await _location.default.emit(locator)}).Count > 0);`
|
|
1017
|
-
}, {
|
|
1018
|
-
level: 0,
|
|
1019
|
-
statement: '}'
|
|
1020
|
-
}];
|
|
1021
|
-
return Promise.resolve({
|
|
1022
|
-
commands
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
async function emitWaitForElementVisible(locator, timeout) {
|
|
1027
|
-
const commands = [{
|
|
1028
|
-
level: 0,
|
|
1029
|
-
statement: '{'
|
|
1030
|
-
}, {
|
|
1031
|
-
level: 1,
|
|
1032
|
-
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`
|
|
1033
|
-
}, {
|
|
1034
|
-
level: 1,
|
|
1035
|
-
statement: `wait.Until(driver => driver.FindElement(${await _location.default.emit(locator)}).Displayed);`
|
|
1036
|
-
}, {
|
|
1037
|
-
level: 0,
|
|
1038
|
-
statement: '}'
|
|
1039
|
-
}];
|
|
1040
|
-
return Promise.resolve({
|
|
1041
|
-
commands
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
async function emitWaitForElementNotEditable(locator, timeout) {
|
|
1046
|
-
const commands = [{
|
|
1047
|
-
level: 0,
|
|
1048
|
-
statement: '{'
|
|
1049
|
-
}, {
|
|
1050
|
-
level: 1,
|
|
1051
|
-
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`
|
|
1052
|
-
}, {
|
|
1053
|
-
level: 1,
|
|
1054
|
-
statement: `wait.Until(driver => !driver.FindElement(${await _location.default.emit(locator)}).Enabled);`
|
|
1055
|
-
}, {
|
|
1056
|
-
level: 0,
|
|
1057
|
-
statement: '}'
|
|
1058
|
-
}];
|
|
1059
|
-
return Promise.resolve({
|
|
1060
|
-
commands
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
async function emitWaitForElementNotPresent(locator, timeout) {
|
|
1065
|
-
const commands = [{
|
|
1066
|
-
level: 0,
|
|
1067
|
-
statement: '{'
|
|
1068
|
-
}, {
|
|
1069
|
-
level: 1,
|
|
1070
|
-
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`
|
|
1071
|
-
}, {
|
|
1072
|
-
level: 1,
|
|
1073
|
-
statement: `wait.Until(driver => driver.FindElements(${await _location.default.emit(locator)}).Count == 0);`
|
|
1074
|
-
}, {
|
|
1075
|
-
level: 0,
|
|
1076
|
-
statement: '}'
|
|
1077
|
-
}];
|
|
1078
|
-
return Promise.resolve({
|
|
1079
|
-
commands
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
|
|
1083
|
-
async function emitWaitForElementNotVisible(locator, timeout) {
|
|
1084
|
-
const commands = [{
|
|
1085
|
-
level: 0,
|
|
1086
|
-
statement: '{'
|
|
1087
|
-
}, {
|
|
1088
|
-
level: 1,
|
|
1089
|
-
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`
|
|
1090
|
-
}, {
|
|
1091
|
-
level: 1,
|
|
1092
|
-
statement: `wait.Until(driver => !driver.FindElement(${await _location.default.emit(locator)}).Displayed);`
|
|
1093
|
-
}, {
|
|
1094
|
-
level: 0,
|
|
1095
|
-
statement: '}'
|
|
1096
|
-
}];
|
|
1097
|
-
return Promise.resolve({
|
|
1098
|
-
commands
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
var _default = {
|
|
1103
|
-
emitters,
|
|
1104
|
-
variableLookup,
|
|
1105
|
-
variableSetter,
|
|
1106
|
-
canEmit,
|
|
1107
|
-
emit,
|
|
1108
|
-
register,
|
|
1109
|
-
extras: {
|
|
1110
|
-
emitWaitForWindow,
|
|
1111
|
-
emitNewWindowHandling
|
|
1112
|
-
}
|
|
1113
|
-
};
|
|
1114
|
-
exports.default = _default;
|