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