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