@seleniumhq/code-export-csharp-commons 3.17.4 → 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.d.ts +30 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +880 -0
- package/dist/command.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/location.d.ts +6 -0
- package/dist/location.d.ts.map +1 -0
- package/dist/location.js +55 -0
- package/dist/location.js.map +1 -0
- package/dist/selection.d.ts +6 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +46 -0
- package/dist/selection.js.map +1 -0
- package/package.json +12 -11
- package/src/{command.js → command.ts} +90 -85
- package/src/{index.js → index.ts} +13 -9
- package/src/{location.js → location.ts} +9 -8
- package/src/{selection.js → selection.ts} +5 -5
- package/tsconfig.json +15 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/.babelrc +0 -13
package/dist/command.js
ADDED
|
@@ -0,0 +1,880 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
3
|
+
// or more contributor license agreements. See the NOTICE file
|
|
4
|
+
// distributed with this work for additional information
|
|
5
|
+
// regarding copyright ownership. The SFC licenses this file
|
|
6
|
+
// to you under the Apache License, Version 2.0 (the
|
|
7
|
+
// "License"); you may not use this file except in compliance
|
|
8
|
+
// with the License. You may obtain a copy of the License at
|
|
9
|
+
//
|
|
10
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
//
|
|
12
|
+
// Unless required by applicable law or agreed to in writing,
|
|
13
|
+
// software distributed under the License is distributed on an
|
|
14
|
+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
// KIND, either express or implied. See the License for the
|
|
16
|
+
// specific language governing permissions and limitations
|
|
17
|
+
// under the License.
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
+
};
|
|
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: emitVerifySelectedValue,
|
|
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: emitVerifySelectedValue,
|
|
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
|
+
waitForText: emitWaitForText,
|
|
120
|
+
webDriverAnswerOnVisiblePrompt: emitAnswerOnNextPrompt,
|
|
121
|
+
webDriverChooseCancelOnVisibleConfirmation: emitChooseCancelOnNextConfirmation,
|
|
122
|
+
webDriverChooseCancelOnVisiblePrompt: emitChooseCancelOnNextConfirmation,
|
|
123
|
+
webDriverChooseOkOnVisibleConfirmation: emitChooseOkOnNextConfirmation,
|
|
124
|
+
while: emitControlFlowWhile,
|
|
125
|
+
};
|
|
126
|
+
side_code_export_1.codeExport.register.preprocessors(exports.emitters);
|
|
127
|
+
function register(command, emitter) {
|
|
128
|
+
side_code_export_1.codeExport.register.emitter({ command, emitter, emitters: exports.emitters });
|
|
129
|
+
}
|
|
130
|
+
function emit(command) {
|
|
131
|
+
return side_code_export_1.codeExport.emit.command(command, exports.emitters[command.command], {
|
|
132
|
+
variableLookup,
|
|
133
|
+
emitNewWindowHandling,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function variableLookup(varName) {
|
|
137
|
+
return `vars["${varName}"].ToString()`;
|
|
138
|
+
}
|
|
139
|
+
function variableSetter(varName, value) {
|
|
140
|
+
return varName ? `vars["${varName}"] = ${value};` : '';
|
|
141
|
+
}
|
|
142
|
+
function emitWaitForWindow() {
|
|
143
|
+
const generateMethodDeclaration = (name) => {
|
|
144
|
+
return `public string ${name}(int timeout) {`;
|
|
145
|
+
};
|
|
146
|
+
const commands = [
|
|
147
|
+
{ level: 0, statement: 'try {' },
|
|
148
|
+
{ level: 1, statement: 'Thread.Sleep(timeout);' },
|
|
149
|
+
{ level: 0, statement: '} catch(Exception e) {' },
|
|
150
|
+
{ level: 1, statement: 'Console.WriteLine("{0} Exception caught.", e);' },
|
|
151
|
+
{ level: 0, statement: '}' },
|
|
152
|
+
{
|
|
153
|
+
level: 0,
|
|
154
|
+
statement: 'var whNow = ((IReadOnlyCollection<object>)driver.WindowHandles).ToList();',
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
level: 0,
|
|
158
|
+
statement: 'var whThen = ((IReadOnlyCollection<object>)vars["WindowHandles"]).ToList();',
|
|
159
|
+
},
|
|
160
|
+
{ level: 0, statement: 'if (whNow.Count > whThen.Count) {' },
|
|
161
|
+
{ level: 1, statement: 'return whNow.Except(whThen).First().ToString();' },
|
|
162
|
+
{ level: 0, statement: '} else {' },
|
|
163
|
+
{ level: 1, statement: 'return whNow.First().ToString();' },
|
|
164
|
+
{ level: 0, statement: '}' },
|
|
165
|
+
];
|
|
166
|
+
return Promise.resolve({
|
|
167
|
+
name: 'waitForWindow',
|
|
168
|
+
commands,
|
|
169
|
+
generateMethodDeclaration,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
async function emitNewWindowHandling(command, emittedCommand) {
|
|
173
|
+
return Promise.resolve(`vars["WindowHandles"] = driver.WindowHandles;\n${await emittedCommand}\nvars["${command.windowHandleName}"] = waitForWindow(${command.windowTimeout});`);
|
|
174
|
+
}
|
|
175
|
+
function emitAssert(varName, value) {
|
|
176
|
+
const _value = value === 'true' || value === 'false'
|
|
177
|
+
? side_code_export_1.codeExport.parsers.capitalize(value)
|
|
178
|
+
: value;
|
|
179
|
+
return Promise.resolve(`Assert.That(vars["${varName}"].ToString(), Is.EqualTo("${_value}"));`);
|
|
180
|
+
}
|
|
181
|
+
function emitAssertAlert(alertText) {
|
|
182
|
+
return Promise.resolve(`Assert.That(driver.SwitchTo().Alert().Text, Is.EqualTo("${alertText}"));`);
|
|
183
|
+
}
|
|
184
|
+
function emitAnswerOnNextPrompt(textToSend) {
|
|
185
|
+
const commands = [
|
|
186
|
+
{ level: 0, statement: '{' },
|
|
187
|
+
{ level: 1, statement: 'var Alert = driver.SwitchTo().Alert();' },
|
|
188
|
+
{ level: 1, statement: `Alert.SendKeys("${textToSend}")` },
|
|
189
|
+
{ level: 1, statement: 'Alert.Accept();' },
|
|
190
|
+
{ level: 0, statement: '}' },
|
|
191
|
+
];
|
|
192
|
+
return Promise.resolve({ commands });
|
|
193
|
+
}
|
|
194
|
+
async function emitCheck(locator) {
|
|
195
|
+
const commands = [
|
|
196
|
+
{ level: 0, statement: '{' },
|
|
197
|
+
{
|
|
198
|
+
level: 1,
|
|
199
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
200
|
+
},
|
|
201
|
+
{ level: 1, statement: 'if (!element.Selected) {' },
|
|
202
|
+
{ level: 2, statement: 'element.Click();' },
|
|
203
|
+
{ level: 1, statement: '}' },
|
|
204
|
+
{ level: 0, statement: '}' },
|
|
205
|
+
];
|
|
206
|
+
return Promise.resolve({ commands });
|
|
207
|
+
}
|
|
208
|
+
function emitChooseCancelOnNextConfirmation() {
|
|
209
|
+
return Promise.resolve(`driver.SwitchTo().Alert().Dismiss();`);
|
|
210
|
+
}
|
|
211
|
+
function emitChooseOkOnNextConfirmation() {
|
|
212
|
+
return Promise.resolve(`driver.SwitchTo().Alert().Accept();`);
|
|
213
|
+
}
|
|
214
|
+
async function emitClick(target) {
|
|
215
|
+
return Promise.resolve(`driver.FindElement(${await location_1.default.emit(target)}).Click();`);
|
|
216
|
+
}
|
|
217
|
+
async function emitClose() {
|
|
218
|
+
return Promise.resolve(`driver.Close();`);
|
|
219
|
+
}
|
|
220
|
+
function generateExpressionScript(script) {
|
|
221
|
+
const scriptString = script.script.replace(/"/g, "'");
|
|
222
|
+
return `(Boolean) js.ExecuteScript("return (${scriptString})"${generateScriptArguments(script)})`;
|
|
223
|
+
}
|
|
224
|
+
function emitControlFlowDo() {
|
|
225
|
+
return Promise.resolve({
|
|
226
|
+
commands: [{ level: 0, statement: 'do {' }],
|
|
227
|
+
endingLevelAdjustment: 1,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function emitControlFlowElse() {
|
|
231
|
+
return Promise.resolve({
|
|
232
|
+
commands: [{ level: 0, statement: '} else {' }],
|
|
233
|
+
startingLevelAdjustment: -1,
|
|
234
|
+
endingLevelAdjustment: +1,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function emitControlFlowElseIf(script) {
|
|
238
|
+
return Promise.resolve({
|
|
239
|
+
commands: [
|
|
240
|
+
{
|
|
241
|
+
level: 0,
|
|
242
|
+
statement: `} else if (${generateExpressionScript(script)}) {`,
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
startingLevelAdjustment: -1,
|
|
246
|
+
endingLevelAdjustment: +1,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function emitControlFlowEnd() {
|
|
250
|
+
return Promise.resolve({
|
|
251
|
+
commands: [{ level: 0, statement: `}` }],
|
|
252
|
+
startingLevelAdjustment: -1,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function emitControlFlowIf(script) {
|
|
256
|
+
return Promise.resolve({
|
|
257
|
+
commands: [
|
|
258
|
+
{ level: 0, statement: `if (${generateExpressionScript(script)}) {` },
|
|
259
|
+
],
|
|
260
|
+
endingLevelAdjustment: 1,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function emitControlFlowForEach(collectionVarName, iteratorVarName) {
|
|
264
|
+
return Promise.resolve({
|
|
265
|
+
commands: [
|
|
266
|
+
{
|
|
267
|
+
level: 0,
|
|
268
|
+
statement: `var ${collectionVarName}Enum = ((IReadOnlyCollection<object>)vars["${collectionVarName}"]).ToList().GetEnumerator();`,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
level: 0,
|
|
272
|
+
statement: `while (${collectionVarName}Enum.MoveNext())`,
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
level: 0,
|
|
276
|
+
statement: `{`,
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
level: 1,
|
|
280
|
+
statement: `vars["${iteratorVarName}"] = ${collectionVarName}Enum.Current;`,
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function emitControlFlowRepeatIf(script) {
|
|
286
|
+
return Promise.resolve({
|
|
287
|
+
commands: [
|
|
288
|
+
{ level: 0, statement: `} while (${generateExpressionScript(script)});` },
|
|
289
|
+
],
|
|
290
|
+
startingLevelAdjustment: -1,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
function emitControlFlowTimes(target) {
|
|
294
|
+
const commands = [
|
|
295
|
+
{ level: 0, statement: `var times = ${target};` },
|
|
296
|
+
{ level: 0, statement: 'for(int i = 0; i < times; i++) {' },
|
|
297
|
+
];
|
|
298
|
+
return Promise.resolve({ commands, endingLevelAdjustment: 1 });
|
|
299
|
+
}
|
|
300
|
+
function emitControlFlowWhile(script) {
|
|
301
|
+
return Promise.resolve({
|
|
302
|
+
commands: [
|
|
303
|
+
{ level: 0, statement: `while (${generateExpressionScript(script)}) {` },
|
|
304
|
+
],
|
|
305
|
+
endingLevelAdjustment: 1,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
async function emitDoubleClick(target) {
|
|
309
|
+
const commands = [
|
|
310
|
+
{ level: 0, statement: '{' },
|
|
311
|
+
{
|
|
312
|
+
level: 1,
|
|
313
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(target)});`,
|
|
314
|
+
},
|
|
315
|
+
{ level: 1, statement: 'Actions builder = new Actions(driver);' },
|
|
316
|
+
{ level: 1, statement: 'builder.DoubleClick(element).Perform();' },
|
|
317
|
+
{ level: 0, statement: '}' },
|
|
318
|
+
];
|
|
319
|
+
return Promise.resolve({ commands });
|
|
320
|
+
}
|
|
321
|
+
async function emitDragAndDrop(dragged, dropped) {
|
|
322
|
+
const commands = [
|
|
323
|
+
{ level: 0, statement: '{' },
|
|
324
|
+
{
|
|
325
|
+
level: 1,
|
|
326
|
+
statement: `var dragged = driver.FindElement(${await location_1.default.emit(dragged)});`,
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
level: 1,
|
|
330
|
+
statement: `var dropped = driver.FindElement(${await location_1.default.emit(dropped)});`,
|
|
331
|
+
},
|
|
332
|
+
{ level: 1, statement: 'Actions builder = new Actions(driver);' },
|
|
333
|
+
{ level: 1, statement: 'builder.DragAndDrop(dragged, dropped).Perform();' },
|
|
334
|
+
{ level: 0, statement: '}' },
|
|
335
|
+
];
|
|
336
|
+
return Promise.resolve({ commands });
|
|
337
|
+
}
|
|
338
|
+
async function emitEcho(message) {
|
|
339
|
+
const _message = message.startsWith('vars[') ? message : `"${message}"`;
|
|
340
|
+
return Promise.resolve(`Console.WriteLine(${_message});`);
|
|
341
|
+
}
|
|
342
|
+
async function emitEditContent(locator, content) {
|
|
343
|
+
const commands = [
|
|
344
|
+
{ level: 0, statement: '{' },
|
|
345
|
+
{
|
|
346
|
+
level: 1,
|
|
347
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
level: 1,
|
|
351
|
+
statement: `js.ExecuteScript("if(arguments[0].contentEditable === 'true') {arguments[0].innerText = '${content}'}", element);`,
|
|
352
|
+
},
|
|
353
|
+
{ level: 0, statement: '}' },
|
|
354
|
+
];
|
|
355
|
+
return Promise.resolve({ commands });
|
|
356
|
+
}
|
|
357
|
+
async function emitExecuteScript(script, varName) {
|
|
358
|
+
const result = `js.ExecuteScript("${script.script}"${generateScriptArguments(script)})`;
|
|
359
|
+
return Promise.resolve(variableSetter(varName, result));
|
|
360
|
+
}
|
|
361
|
+
async function emitExecuteAsyncScript(script, varName) {
|
|
362
|
+
const result = `js.executeAsyncScript("var callback = arguments[arguments.length - 1];${script.script}.then(callback).catch(callback);${generateScriptArguments(script)}")`;
|
|
363
|
+
return Promise.resolve(variableSetter(varName, result));
|
|
364
|
+
}
|
|
365
|
+
function generateScriptArguments(script) {
|
|
366
|
+
return `${script.argv.length ? ', ' : ''}${script.argv
|
|
367
|
+
.map((varName) => `vars["${varName}"]`)
|
|
368
|
+
.join(',')}`;
|
|
369
|
+
}
|
|
370
|
+
async function emitMouseDown(locator) {
|
|
371
|
+
const commands = [
|
|
372
|
+
{ level: 0, statement: '{' },
|
|
373
|
+
{
|
|
374
|
+
level: 1,
|
|
375
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
376
|
+
},
|
|
377
|
+
{ level: 1, statement: 'Actions builder = new Actions(driver);' },
|
|
378
|
+
{
|
|
379
|
+
level: 1,
|
|
380
|
+
statement: 'builder.MoveToElement(element).ClickAndHold().Perform();',
|
|
381
|
+
},
|
|
382
|
+
{ level: 0, statement: '}' },
|
|
383
|
+
];
|
|
384
|
+
return Promise.resolve({ commands });
|
|
385
|
+
}
|
|
386
|
+
async function emitMouseMove(locator) {
|
|
387
|
+
const commands = [
|
|
388
|
+
{ level: 0, statement: '{' },
|
|
389
|
+
{
|
|
390
|
+
level: 1,
|
|
391
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
392
|
+
},
|
|
393
|
+
{ level: 1, statement: 'Actions builder = new Actions(driver);' },
|
|
394
|
+
{ level: 1, statement: 'builder.MoveToElement(element).Perform();' },
|
|
395
|
+
{ level: 0, statement: '}' },
|
|
396
|
+
];
|
|
397
|
+
return Promise.resolve({ commands });
|
|
398
|
+
}
|
|
399
|
+
async function emitMouseOut() {
|
|
400
|
+
const commands = [
|
|
401
|
+
{ level: 0, statement: '{' },
|
|
402
|
+
{
|
|
403
|
+
level: 1,
|
|
404
|
+
statement: `var element = driver.FindElement(By.tagName("body"));`,
|
|
405
|
+
},
|
|
406
|
+
{ level: 1, statement: 'Actions builder = new Actions(driver);' },
|
|
407
|
+
{ level: 1, statement: 'builder.MoveToElement(element, 0, 0).Perform();' },
|
|
408
|
+
{ level: 0, statement: '}' },
|
|
409
|
+
];
|
|
410
|
+
return Promise.resolve({ commands });
|
|
411
|
+
}
|
|
412
|
+
async function emitMouseUp(locator) {
|
|
413
|
+
const commands = [
|
|
414
|
+
{ level: 0, statement: '{' },
|
|
415
|
+
{
|
|
416
|
+
level: 1,
|
|
417
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
418
|
+
},
|
|
419
|
+
{ level: 1, statement: 'Actions builder = new Actions(driver);' },
|
|
420
|
+
{
|
|
421
|
+
level: 1,
|
|
422
|
+
statement: 'builder.MoveToElement(element).Release().Perform();',
|
|
423
|
+
},
|
|
424
|
+
{ level: 0, statement: '}' },
|
|
425
|
+
];
|
|
426
|
+
return Promise.resolve({ commands });
|
|
427
|
+
}
|
|
428
|
+
function emitOpen(target) {
|
|
429
|
+
const url = /^(file|http|https):\/\//.test(target)
|
|
430
|
+
? `"${target}"`
|
|
431
|
+
: // @ts-expect-error globals yuck
|
|
432
|
+
`"${global.baseUrl}${target}"`;
|
|
433
|
+
return Promise.resolve(`driver.Navigate().GoToUrl(${url});`);
|
|
434
|
+
}
|
|
435
|
+
async function emitPause(time) {
|
|
436
|
+
const commands = [
|
|
437
|
+
{ level: 0, statement: 'try {' },
|
|
438
|
+
{ level: 1, statement: `Thread.Sleep(${time});` },
|
|
439
|
+
{ level: 0, statement: '} catch (Exception e) {' },
|
|
440
|
+
{ level: 1, statement: 'Console.WriteLine("{0} Exception caught.", e);' },
|
|
441
|
+
{ level: 0, statement: '}' },
|
|
442
|
+
];
|
|
443
|
+
return Promise.resolve({ commands });
|
|
444
|
+
}
|
|
445
|
+
async function emitRun(testName) {
|
|
446
|
+
return Promise.resolve(`${side_code_export_1.codeExport.parsers.sanitizeName(testName)}();`);
|
|
447
|
+
}
|
|
448
|
+
async function emitRunScript(script) {
|
|
449
|
+
return Promise.resolve(`js.ExecuteScript("${script.script}${generateScriptArguments(script)}");`);
|
|
450
|
+
}
|
|
451
|
+
async function emitSetWindowSize(size) {
|
|
452
|
+
const [width, height] = size.split('x');
|
|
453
|
+
return Promise.resolve(`driver.Manage().Window.Size = new System.Drawing.Size(${width}, ${height});`);
|
|
454
|
+
}
|
|
455
|
+
async function emitSelect(selectElement, option) {
|
|
456
|
+
const commands = [
|
|
457
|
+
{ level: 0, statement: '{' },
|
|
458
|
+
{
|
|
459
|
+
level: 1,
|
|
460
|
+
statement: `var dropdown = driver.FindElement(${await location_1.default.emit(selectElement)});`,
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
level: 1,
|
|
464
|
+
statement: `dropdown.FindElement(${await selection_1.default.emit(option)}).Click();`,
|
|
465
|
+
},
|
|
466
|
+
{ level: 0, statement: '}' },
|
|
467
|
+
];
|
|
468
|
+
return { commands };
|
|
469
|
+
}
|
|
470
|
+
async function emitSelectFrame(frameLocation) {
|
|
471
|
+
if (frameLocation === 'relative=top' || frameLocation === 'relative=parent') {
|
|
472
|
+
return Promise.resolve('driver.SwitchTo().DefaultContent();');
|
|
473
|
+
}
|
|
474
|
+
else if (/^index=/.test(frameLocation)) {
|
|
475
|
+
return Promise.resolve(`driver.SwitchTo().Frame(${Math.floor(Number(frameLocation.split('index=')[1]))});`);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
478
|
+
return Promise.resolve({
|
|
479
|
+
commands: [
|
|
480
|
+
{ level: 0, statement: '{' },
|
|
481
|
+
{
|
|
482
|
+
level: 1,
|
|
483
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(frameLocation)});`,
|
|
484
|
+
},
|
|
485
|
+
{ level: 1, statement: 'driver.SwitchTo().Frame(element);' },
|
|
486
|
+
{ level: 0, statement: '}' },
|
|
487
|
+
],
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
async function emitSelectWindow(windowLocation) {
|
|
492
|
+
if (/^handle=/.test(windowLocation)) {
|
|
493
|
+
return Promise.resolve(`driver.SwitchTo().Window(${windowLocation.split('handle=')[1]});`);
|
|
494
|
+
}
|
|
495
|
+
else if (/^name=/.test(windowLocation)) {
|
|
496
|
+
return Promise.resolve(`driver.SwitchTo().Window("${windowLocation.split('name=')[1]}");`);
|
|
497
|
+
}
|
|
498
|
+
else if (/^win_ser_/.test(windowLocation)) {
|
|
499
|
+
if (windowLocation === 'win_ser_local') {
|
|
500
|
+
return Promise.resolve({
|
|
501
|
+
commands: [
|
|
502
|
+
{ level: 0, statement: '{' },
|
|
503
|
+
{
|
|
504
|
+
level: 1,
|
|
505
|
+
statement: 'ArrayList<string> handles = new ArrayList<string>(driver.WindowHandles());',
|
|
506
|
+
},
|
|
507
|
+
{ level: 1, statement: 'driver.SwitchTo().Window(handles[0]);' },
|
|
508
|
+
{ level: 0, statement: '}' },
|
|
509
|
+
],
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
const index = parseInt(windowLocation.substr('win_ser_'.length));
|
|
514
|
+
return Promise.resolve({
|
|
515
|
+
commands: [
|
|
516
|
+
{ level: 0, statement: '{' },
|
|
517
|
+
{
|
|
518
|
+
level: 1,
|
|
519
|
+
statement: 'ArrayList<string> handles = new ArrayList<string>(driver.WindowHandles);',
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
level: 1,
|
|
523
|
+
statement: `driver.SwitchTo().Window(handles[${index}]);`,
|
|
524
|
+
},
|
|
525
|
+
{ level: 0, statement: '}' },
|
|
526
|
+
],
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
return Promise.reject(new Error('Can only emit `select window` using handles'));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function generateSendKeysInput(value) {
|
|
535
|
+
if (Array.isArray(value)) {
|
|
536
|
+
return value
|
|
537
|
+
.map((s) => {
|
|
538
|
+
if (s.startsWith('vars[')) {
|
|
539
|
+
return s;
|
|
540
|
+
}
|
|
541
|
+
else if (s.startsWith('Key[')) {
|
|
542
|
+
const key = s.match(/\['(.*)'\]/)[1];
|
|
543
|
+
return `Keys.${side_code_export_1.codeExport.parsers.capitalize(key.toLowerCase())}`;
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
return `"${s}"`;
|
|
547
|
+
}
|
|
548
|
+
})
|
|
549
|
+
.join(' + ');
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
if (value.startsWith('vars[')) {
|
|
553
|
+
return value;
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
return `"${value}"`;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
async function emitSendKeys(target, value) {
|
|
561
|
+
return Promise.resolve(`driver.FindElement(${await location_1.default.emit(target)}).SendKeys(${generateSendKeysInput(value)});`);
|
|
562
|
+
}
|
|
563
|
+
function emitSetSpeed() {
|
|
564
|
+
return Promise.resolve(`Console.WriteLine("\`set speed\` is a no-op in code export, use \`pause\` instead");`);
|
|
565
|
+
}
|
|
566
|
+
async function emitStore(value, varName) {
|
|
567
|
+
return Promise.resolve(variableSetter(varName, `"${value}"`));
|
|
568
|
+
}
|
|
569
|
+
async function emitStoreAttribute(locator, varName) {
|
|
570
|
+
const attributePos = locator.lastIndexOf('@');
|
|
571
|
+
const elementLocator = locator.slice(0, attributePos);
|
|
572
|
+
const attributeName = locator.slice(attributePos + 1);
|
|
573
|
+
const commands = [
|
|
574
|
+
{ level: 0, statement: '{' },
|
|
575
|
+
{
|
|
576
|
+
level: 1,
|
|
577
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(elementLocator)});`,
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
level: 1,
|
|
581
|
+
statement: `string attribute = element.GetAttribute("${attributeName}");`,
|
|
582
|
+
},
|
|
583
|
+
{ level: 1, statement: `${variableSetter(varName, 'attribute')}` },
|
|
584
|
+
{ level: 0, statement: '}' },
|
|
585
|
+
];
|
|
586
|
+
return Promise.resolve({ commands });
|
|
587
|
+
}
|
|
588
|
+
async function emitStoreJson(_json, _varName) {
|
|
589
|
+
return Promise.resolve('throw new System.Exception("The `storeJson` command is not yet implemented for this language.");');
|
|
590
|
+
}
|
|
591
|
+
async function emitStoreText(locator, varName) {
|
|
592
|
+
const result = `driver.FindElement(${await location_1.default.emit(locator)}).Text`;
|
|
593
|
+
return Promise.resolve(variableSetter(varName, result));
|
|
594
|
+
}
|
|
595
|
+
async function emitStoreTitle(_, varName) {
|
|
596
|
+
return Promise.resolve(variableSetter(varName, 'driver.Title'));
|
|
597
|
+
}
|
|
598
|
+
async function emitStoreValue(locator, varName) {
|
|
599
|
+
const result = `driver.FindElement(${await location_1.default.emit(locator)}).GetAttribute("value")`;
|
|
600
|
+
return Promise.resolve(variableSetter(varName, result));
|
|
601
|
+
}
|
|
602
|
+
async function emitStoreWindowHandle(varName) {
|
|
603
|
+
return Promise.resolve(variableSetter(varName, 'driver.CurrentWindowHandle'));
|
|
604
|
+
}
|
|
605
|
+
async function emitStoreXpathCount(locator, varName) {
|
|
606
|
+
const result = `driver.FindElements(${await location_1.default.emit(locator)}).Count`;
|
|
607
|
+
return Promise.resolve(variableSetter(varName, result));
|
|
608
|
+
}
|
|
609
|
+
async function emitSubmit(_locator) {
|
|
610
|
+
return Promise.resolve(`throw new System.Exception("\`submit\` is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.");`);
|
|
611
|
+
}
|
|
612
|
+
async function emitType(target, value) {
|
|
613
|
+
return Promise.resolve(`driver.FindElement(${await location_1.default.emit(target)}).SendKeys(${generateSendKeysInput(value)});`);
|
|
614
|
+
}
|
|
615
|
+
async function emitUncheck(locator) {
|
|
616
|
+
const commands = [
|
|
617
|
+
{ level: 0, statement: '{' },
|
|
618
|
+
{
|
|
619
|
+
level: 1,
|
|
620
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
621
|
+
},
|
|
622
|
+
{ level: 1, statement: 'if (element.Selected) {' },
|
|
623
|
+
{ level: 2, statement: 'element.Click();' },
|
|
624
|
+
{ level: 1, statement: '}' },
|
|
625
|
+
{ level: 0, statement: '}' },
|
|
626
|
+
];
|
|
627
|
+
return Promise.resolve({ commands });
|
|
628
|
+
}
|
|
629
|
+
async function emitVerifyChecked(locator) {
|
|
630
|
+
return Promise.resolve(`Assert.True(driver.FindElement(${await location_1.default.emit(locator)}).Selected);`);
|
|
631
|
+
}
|
|
632
|
+
async function emitVerifyEditable(locator) {
|
|
633
|
+
const commands = [
|
|
634
|
+
{ level: 0, statement: '{' },
|
|
635
|
+
{
|
|
636
|
+
level: 1,
|
|
637
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
level: 1,
|
|
641
|
+
statement: 'Boolean isEditable = element.Enabled && element.GetAttribute("readonly") == null;',
|
|
642
|
+
},
|
|
643
|
+
{ level: 1, statement: 'Assert.True(isEditable);' },
|
|
644
|
+
{ level: 0, statement: '}' },
|
|
645
|
+
];
|
|
646
|
+
return Promise.resolve({ commands });
|
|
647
|
+
}
|
|
648
|
+
async function emitVerifyElementPresent(locator) {
|
|
649
|
+
const commands = [
|
|
650
|
+
{
|
|
651
|
+
level: 0,
|
|
652
|
+
statement: `var elements = driver.FindElements(${await location_1.default.emit(locator)});`,
|
|
653
|
+
},
|
|
654
|
+
{ level: 0, statement: 'Assert.True(elements.Count > 0);' },
|
|
655
|
+
];
|
|
656
|
+
return Promise.resolve({ commands });
|
|
657
|
+
}
|
|
658
|
+
async function emitVerifyElementNotPresent(locator) {
|
|
659
|
+
const commands = [
|
|
660
|
+
{ level: 0, statement: '{' },
|
|
661
|
+
{
|
|
662
|
+
level: 1,
|
|
663
|
+
statement: `var elements = driver.FindElements(${await location_1.default.emit(locator)});`,
|
|
664
|
+
},
|
|
665
|
+
{ level: 1, statement: 'Assert.True(elements.Count == 0);' },
|
|
666
|
+
{ level: 0, statement: '}' },
|
|
667
|
+
];
|
|
668
|
+
return Promise.resolve({ commands });
|
|
669
|
+
}
|
|
670
|
+
async function emitVerifyNotChecked(locator) {
|
|
671
|
+
return Promise.resolve(`Assert.False(driver.FindElement(${await location_1.default.emit(locator)}).Selected);`);
|
|
672
|
+
}
|
|
673
|
+
async function emitVerifyNotEditable(locator) {
|
|
674
|
+
const commands = [
|
|
675
|
+
{ level: 0, statement: '{' },
|
|
676
|
+
{
|
|
677
|
+
level: 1,
|
|
678
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
level: 1,
|
|
682
|
+
statement: 'Boolean isEditable = element.Enabled && element.GetAttribute("readonly") == null;',
|
|
683
|
+
},
|
|
684
|
+
{ level: 1, statement: 'Assert.False(isEditable);' },
|
|
685
|
+
{ level: 0, statement: '}' },
|
|
686
|
+
];
|
|
687
|
+
return Promise.resolve({ commands });
|
|
688
|
+
}
|
|
689
|
+
async function emitVerifyNotSelectedValue(locator, expectedValue) {
|
|
690
|
+
const commands = [
|
|
691
|
+
{ level: 0, statement: '{' },
|
|
692
|
+
{
|
|
693
|
+
level: 1,
|
|
694
|
+
statement: `string value = driver.FindElement(${await location_1.default.emit(locator)}).GetAttribute("value");`,
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
level: 1,
|
|
698
|
+
statement: `Assert.That(value, Is.Not.EqualTo("${side_code_export_1.codeExport.emit.text(expectedValue)}"));`,
|
|
699
|
+
},
|
|
700
|
+
{ level: 0, statement: '}' },
|
|
701
|
+
];
|
|
702
|
+
return Promise.resolve({ commands });
|
|
703
|
+
}
|
|
704
|
+
async function emitVerifyNotText(locator, text) {
|
|
705
|
+
const result = `driver.FindElement(${await location_1.default.emit(locator)}).Text`;
|
|
706
|
+
return Promise.resolve(`Assert.That(${result}, Is.Not.EqualTo("${side_code_export_1.codeExport.emit.text(text)}"));`);
|
|
707
|
+
}
|
|
708
|
+
async function emitVerifySelectedLabel(locator, labelValue) {
|
|
709
|
+
const commands = [
|
|
710
|
+
{ level: 0, statement: '{' },
|
|
711
|
+
{
|
|
712
|
+
level: 1,
|
|
713
|
+
statement: `var element = driver.FindElement(${await location_1.default.emit(locator)});`,
|
|
714
|
+
},
|
|
715
|
+
{ level: 1, statement: 'string value = element.GetAttribute("value");' },
|
|
716
|
+
{
|
|
717
|
+
level: 1,
|
|
718
|
+
statement: `string locator = string.Format("option[@value='%s']", value);`,
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
level: 1,
|
|
722
|
+
statement: 'string selectedText = element.FindElement(By.XPath(locator)).Text;',
|
|
723
|
+
},
|
|
724
|
+
{
|
|
725
|
+
level: 1,
|
|
726
|
+
statement: `Assert.That(selectedText, Is.EqualTo("${labelValue}"));`,
|
|
727
|
+
},
|
|
728
|
+
{ level: 0, statement: '}' },
|
|
729
|
+
];
|
|
730
|
+
return Promise.resolve({
|
|
731
|
+
commands,
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
async function emitVerifySelectedValue(locator, value) {
|
|
735
|
+
return emitVerifyValue(locator, value);
|
|
736
|
+
}
|
|
737
|
+
async function emitVerifyText(locator, text) {
|
|
738
|
+
return Promise.resolve(`Assert.That(driver.FindElement(${await location_1.default.emit(locator)}).Text, Is.EqualTo("${side_code_export_1.codeExport.emit.text(text)}"));`);
|
|
739
|
+
}
|
|
740
|
+
async function emitVerifyValue(locator, value) {
|
|
741
|
+
const commands = [
|
|
742
|
+
{ level: 0, statement: '{' },
|
|
743
|
+
{
|
|
744
|
+
level: 1,
|
|
745
|
+
statement: `string value = driver.FindElement(${await location_1.default.emit(locator)}).GetAttribute("value");`,
|
|
746
|
+
},
|
|
747
|
+
{ level: 1, statement: `Assert.That(value, Is.EqualTo("${value}"));` },
|
|
748
|
+
{ level: 0, statement: '}' },
|
|
749
|
+
];
|
|
750
|
+
return Promise.resolve({ commands });
|
|
751
|
+
}
|
|
752
|
+
async function emitVerifyTitle(title) {
|
|
753
|
+
return Promise.resolve(`Assert.That(driver.Title, Is.EqualTo("${title}"));`);
|
|
754
|
+
}
|
|
755
|
+
async function emitWaitForElementEditable(locator, timeout) {
|
|
756
|
+
const commands = [
|
|
757
|
+
{ level: 0, statement: '{' },
|
|
758
|
+
{
|
|
759
|
+
level: 1,
|
|
760
|
+
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`,
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
level: 1,
|
|
764
|
+
statement: `wait.Until(driver => driver.FindElement(${await location_1.default.emit(locator)}).Enabled);`,
|
|
765
|
+
},
|
|
766
|
+
{ level: 0, statement: '}' },
|
|
767
|
+
];
|
|
768
|
+
return Promise.resolve({ commands });
|
|
769
|
+
}
|
|
770
|
+
async function emitWaitForText(locator, text) {
|
|
771
|
+
const timeout = 30000;
|
|
772
|
+
const commands = [
|
|
773
|
+
{ level: 0, statement: '{' },
|
|
774
|
+
{
|
|
775
|
+
level: 1,
|
|
776
|
+
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`,
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
level: 1,
|
|
780
|
+
statement: `wait.Until(driver => driver.FindElement(${await location_1.default.emit(locator)}).Text == "${text}");`,
|
|
781
|
+
},
|
|
782
|
+
{ level: 0, statement: '}' },
|
|
783
|
+
];
|
|
784
|
+
return Promise.resolve({ commands });
|
|
785
|
+
}
|
|
786
|
+
function skip() {
|
|
787
|
+
return Promise.resolve('');
|
|
788
|
+
}
|
|
789
|
+
async function emitWaitForElementPresent(locator, timeout) {
|
|
790
|
+
const commands = [
|
|
791
|
+
{ level: 0, statement: '{' },
|
|
792
|
+
{
|
|
793
|
+
level: 1,
|
|
794
|
+
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`,
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
level: 1,
|
|
798
|
+
statement: `wait.Until(driver => driver.FindElements(${await location_1.default.emit(locator)}).Count > 0);`,
|
|
799
|
+
},
|
|
800
|
+
{ level: 0, statement: '}' },
|
|
801
|
+
];
|
|
802
|
+
return Promise.resolve({ commands });
|
|
803
|
+
}
|
|
804
|
+
async function emitWaitForElementVisible(locator, timeout) {
|
|
805
|
+
const commands = [
|
|
806
|
+
{ level: 0, statement: '{' },
|
|
807
|
+
{
|
|
808
|
+
level: 1,
|
|
809
|
+
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`,
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
level: 1,
|
|
813
|
+
statement: `wait.Until(driver => driver.FindElement(${await location_1.default.emit(locator)}).Displayed);`,
|
|
814
|
+
},
|
|
815
|
+
{ level: 0, statement: '}' },
|
|
816
|
+
];
|
|
817
|
+
return Promise.resolve({
|
|
818
|
+
commands,
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
async function emitWaitForElementNotEditable(locator, timeout) {
|
|
822
|
+
const commands = [
|
|
823
|
+
{ level: 0, statement: '{' },
|
|
824
|
+
{
|
|
825
|
+
level: 1,
|
|
826
|
+
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`,
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
level: 1,
|
|
830
|
+
statement: `wait.Until(driver => !driver.FindElement(${await location_1.default.emit(locator)}).Enabled);`,
|
|
831
|
+
},
|
|
832
|
+
{ level: 0, statement: '}' },
|
|
833
|
+
];
|
|
834
|
+
return Promise.resolve({
|
|
835
|
+
commands,
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
async function emitWaitForElementNotPresent(locator, timeout) {
|
|
839
|
+
const commands = [
|
|
840
|
+
{ level: 0, statement: '{' },
|
|
841
|
+
{
|
|
842
|
+
level: 1,
|
|
843
|
+
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`,
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
level: 1,
|
|
847
|
+
statement: `wait.Until(driver => driver.FindElements(${await location_1.default.emit(locator)}).Count == 0);`,
|
|
848
|
+
},
|
|
849
|
+
{ level: 0, statement: '}' },
|
|
850
|
+
];
|
|
851
|
+
return Promise.resolve({
|
|
852
|
+
commands,
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
async function emitWaitForElementNotVisible(locator, timeout) {
|
|
856
|
+
const commands = [
|
|
857
|
+
{ level: 0, statement: '{' },
|
|
858
|
+
{
|
|
859
|
+
level: 1,
|
|
860
|
+
statement: `WebDriverWait wait = new WebDriverWait(driver, System.TimeSpan.FromSeconds(${Math.floor(timeout / 1000)}));`,
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
level: 1,
|
|
864
|
+
statement: `wait.Until(driver => !driver.FindElement(${await location_1.default.emit(locator)}).Displayed);`,
|
|
865
|
+
},
|
|
866
|
+
{ level: 0, statement: '}' },
|
|
867
|
+
];
|
|
868
|
+
return Promise.resolve({
|
|
869
|
+
commands,
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
exports.default = {
|
|
873
|
+
emitters: exports.emitters,
|
|
874
|
+
variableLookup,
|
|
875
|
+
variableSetter,
|
|
876
|
+
emit,
|
|
877
|
+
register,
|
|
878
|
+
extras: { emitWaitForWindow, emitNewWindowHandling },
|
|
879
|
+
};
|
|
880
|
+
//# sourceMappingURL=command.js.map
|