@seleniumhq/code-export-python-pytest 4.0.12 → 4.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__test__/src/__snapshots__/command.spec.js.snap +52 -31
- package/__test__/src/__snapshots__/index.spec.js.snap +40 -10
- package/__test__/src/__snapshots__/location.spec.js.snap +1 -1
- package/__test__/src/command.spec.js +103 -59
- package/__test__/src/index.spec.js +134 -59
- package/__test__/src/selection.spec.js +9 -6
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +54 -41
- package/dist/command.js.map +1 -1
- package/dist/hook.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/location.js +1 -2
- package/dist/location.js.map +1 -1
- package/dist/selection.js +1 -5
- package/dist/selection.js.map +1 -1
- package/jest.config.js +14 -0
- package/package.json +4 -3
- package/src/command.ts +92 -47
- package/src/hook.ts +1 -1
- package/src/index.ts +3 -0
- package/src/selection.ts +0 -3
- package/tsconfig.tsbuildinfo +1 -1
package/dist/location.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// specific language governing permissions and limitations
|
|
17
17
|
// under the License.
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.emit =
|
|
19
|
+
exports.emit = emit;
|
|
20
20
|
const side_code_export_1 = require("side-code-export");
|
|
21
21
|
const emitters = {
|
|
22
22
|
id: emitId,
|
|
@@ -30,7 +30,6 @@ const emitters = {
|
|
|
30
30
|
function emit(location) {
|
|
31
31
|
return side_code_export_1.codeExport.emit.location(location, emitters);
|
|
32
32
|
}
|
|
33
|
-
exports.emit = emit;
|
|
34
33
|
exports.default = {
|
|
35
34
|
emit,
|
|
36
35
|
};
|
package/dist/location.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"location.js","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,wDAAwD;AACxD,6DAA6D;AAC7D,oDAAoD;AACpD,6DAA6D;AAC7D,6DAA6D;AAC7D,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,6DAA6D;AAC7D,8DAA8D;AAC9D,yDAAyD;AACzD,4DAA4D;AAC5D,0DAA0D;AAC1D,qBAAqB
|
|
1
|
+
{"version":3,"file":"location.js","sourceRoot":"","sources":["../src/location.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,wDAAwD;AACxD,6DAA6D;AAC7D,oDAAoD;AACpD,6DAA6D;AAC7D,6DAA6D;AAC7D,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,6DAA6D;AAC7D,8DAA8D;AAC9D,yDAAyD;AACzD,4DAA4D;AAC5D,0DAA0D;AAC1D,qBAAqB;;AAcrB,oBAEC;AAdD,uDAAyD;AAEzD,MAAM,QAAQ,GAAG;IACf,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,QAAQ;IAClB,eAAe,EAAE,mBAAmB;IACpC,GAAG,EAAE,OAAO;IACZ,KAAK,EAAE,SAAS;CACjB,CAAA;AAED,SAAgB,IAAI,CAAC,QAAgB;IACnC,OAAO,6BAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACnD,CAAC;AAED,kBAAe;IACb,IAAI;CACL,CAAA;AAED,SAAS,MAAM,CAAC,QAAgB;IAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,QAAQ,GAAG,CAAC,CAAA;AAChD,CAAC;AAED,SAAS,QAAQ,CAAC,QAAgB;IAChC,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,QAAQ,GAAG,CAAC,CAAA;AAClD,CAAC;AAED,SAAS,QAAQ,CAAC,QAAgB;IAChC,OAAO,OAAO,CAAC,OAAO,CAAC,kBAAkB,QAAQ,GAAG,CAAC,CAAA;AACvD,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB;IAC3C,OAAO,OAAO,CAAC,OAAO,CAAC,0BAA0B,QAAQ,GAAG,CAAC,CAAA;AAC/D,CAAC;AAED,SAAS,OAAO,CAAC,QAAgB;IAC/B,OAAO,OAAO,CAAC,OAAO,CAAC,qBAAqB,QAAQ,GAAG,CAAC,CAAA;AAC1D,CAAC;AAED,SAAS,SAAS,CAAC,QAAgB;IACjC,OAAO,OAAO,CAAC,OAAO,CAAC,cAAc,QAAQ,GAAG,CAAC,CAAA;AACnD,CAAC"}
|
package/dist/selection.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// specific language governing permissions and limitations
|
|
17
17
|
// under the License.
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.emit =
|
|
19
|
+
exports.emit = emit;
|
|
20
20
|
const side_code_export_1 = require("side-code-export");
|
|
21
21
|
const emitters = {
|
|
22
22
|
id: emitId,
|
|
@@ -27,7 +27,6 @@ const emitters = {
|
|
|
27
27
|
function emit(location) {
|
|
28
28
|
return side_code_export_1.codeExport.emit.selection(location, emitters);
|
|
29
29
|
}
|
|
30
|
-
exports.emit = emit;
|
|
31
30
|
exports.default = {
|
|
32
31
|
emit,
|
|
33
32
|
};
|
|
@@ -38,9 +37,6 @@ function emitValue(value) {
|
|
|
38
37
|
return Promise.resolve(`By.CSS_SELECTOR, "*[value='${value}']"`);
|
|
39
38
|
}
|
|
40
39
|
function emitLabel(label) {
|
|
41
|
-
if (label.startsWith('self.vars[')) {
|
|
42
|
-
return Promise.resolve(`By.XPATH, "//option[. = '{}']".format(${label})`);
|
|
43
|
-
}
|
|
44
40
|
return Promise.resolve(`By.XPATH, "//option[. = '${label}']"`);
|
|
45
41
|
}
|
|
46
42
|
function emitIndex(index) {
|
package/dist/selection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../src/selection.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,wDAAwD;AACxD,6DAA6D;AAC7D,oDAAoD;AACpD,6DAA6D;AAC7D,6DAA6D;AAC7D,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,6DAA6D;AAC7D,8DAA8D;AAC9D,yDAAyD;AACzD,4DAA4D;AAC5D,0DAA0D;AAC1D,qBAAqB
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../src/selection.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,+DAA+D;AAC/D,wDAAwD;AACxD,6DAA6D;AAC7D,oDAAoD;AACpD,6DAA6D;AAC7D,6DAA6D;AAC7D,EAAE;AACF,+CAA+C;AAC/C,EAAE;AACF,6DAA6D;AAC7D,8DAA8D;AAC9D,yDAAyD;AACzD,4DAA4D;AAC5D,0DAA0D;AAC1D,qBAAqB;;AAWrB,oBAEC;AAXD,uDAAyD;AAEzD,MAAM,QAAQ,GAAG;IACf,EAAE,EAAE,MAAM;IACV,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;CACjB,CAAA;AAED,SAAgB,IAAI,CAAC,QAAgB;IACnC,OAAO,6BAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACpD,CAAC;AAED,kBAAe;IACb,IAAI;CACL,CAAA;AAED,SAAS,MAAM,CAAC,EAAU;IACxB,OAAO,OAAO,CAAC,OAAO,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;AAC5D,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,8BAA8B,KAAK,KAAK,CAAC,CAAA;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,4BAA4B,KAAK,KAAK,CAAC,CAAA;AAChE,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,OAAO,CAAC,OAAO,CAAC,iCAAiC,KAAK,IAAI,CAAC,CAAA;AACpE,CAAC"}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
// The snapshots were written with the format from before Jest 29
|
|
3
|
+
snapshotFormat: { escapeString: true, printBasicPrototype: true },
|
|
4
|
+
testEnvironmentOptions: {
|
|
5
|
+
url: 'http://localhost/index.html',
|
|
6
|
+
},
|
|
7
|
+
testMatch: ['**/packages/**/__test?(s)__/**/*.spec.[jt]s?(x)'],
|
|
8
|
+
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
|
|
9
|
+
transform: {
|
|
10
|
+
// Find the repo's babel.config.js from the package folder
|
|
11
|
+
'^.+\\.jsx?$': ['babel-jest', { rootMode: 'upward' }],
|
|
12
|
+
'^.+\\.ts?$': 'ts-jest',
|
|
13
|
+
},
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seleniumhq/code-export-python-pytest",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.1.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Export Selenium IDE project contents to Python pytest",
|
|
6
6
|
"repository": "https://github.com/SeleniumHQ/selenium-ide",
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"license": "Apache-2.0",
|
|
13
13
|
"main": "dist/index.js",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"side-code-export": "
|
|
15
|
+
"side-code-export": "4.1.0-beta.1"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@seleniumhq/side-
|
|
18
|
+
"@seleniumhq/side-runtime": "4.1.0-beta.1",
|
|
19
|
+
"@seleniumhq/side-model": "4.1.0-beta.1"
|
|
19
20
|
},
|
|
20
21
|
"gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744",
|
|
21
22
|
"scripts": {
|
package/src/command.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
PrebuildEmitter,
|
|
23
23
|
ProcessedCommandEmitter,
|
|
24
24
|
ScriptShape,
|
|
25
|
+
hasVariable,
|
|
25
26
|
} from 'side-code-export'
|
|
26
27
|
// eslint-disable-next-line node/no-unpublished-import
|
|
27
28
|
import { CommandShape } from '@seleniumhq/side-model'
|
|
@@ -30,7 +31,6 @@ import selection from './selection'
|
|
|
30
31
|
|
|
31
32
|
export const emitters: Record<string, ProcessedCommandEmitter> = {
|
|
32
33
|
addSelection: emitSelect,
|
|
33
|
-
answerOnNextPrompt: skip,
|
|
34
34
|
assert: emitAssert,
|
|
35
35
|
assertAlert: emitAssertAlert,
|
|
36
36
|
assertChecked: emitVerifyChecked,
|
|
@@ -49,9 +49,6 @@ export const emitters: Record<string, ProcessedCommandEmitter> = {
|
|
|
49
49
|
assertText: emitVerifyText,
|
|
50
50
|
assertTitle: emitVerifyTitle,
|
|
51
51
|
check: emitCheck,
|
|
52
|
-
chooseCancelOnNextConfirmation: skip,
|
|
53
|
-
chooseCancelOnNextPrompt: skip,
|
|
54
|
-
chooseOkOnNextConfirmation: skip,
|
|
55
52
|
click: emitClick,
|
|
56
53
|
clickAt: emitClick,
|
|
57
54
|
close: emitClose,
|
|
@@ -71,7 +68,6 @@ export const emitters: Record<string, ProcessedCommandEmitter> = {
|
|
|
71
68
|
if: emitControlFlowIf,
|
|
72
69
|
mouseDown: emitMouseDown,
|
|
73
70
|
mouseDownAt: emitMouseDown,
|
|
74
|
-
mouseMove: emitMouseMove,
|
|
75
71
|
mouseMoveAt: emitMouseMove,
|
|
76
72
|
mouseOver: emitMouseMove,
|
|
77
73
|
mouseOut: emitMouseOut,
|
|
@@ -96,8 +92,7 @@ export const emitters: Record<string, ProcessedCommandEmitter> = {
|
|
|
96
92
|
storeTitle: emitStoreTitle,
|
|
97
93
|
storeValue: emitStoreValue,
|
|
98
94
|
storeWindowHandle: emitStoreWindowHandle,
|
|
99
|
-
|
|
100
|
-
submit: emitSubmit,
|
|
95
|
+
storeElementCount: emitStoreXpathCount,
|
|
101
96
|
times: emitControlFlowTimes,
|
|
102
97
|
type: emitType,
|
|
103
98
|
uncheck: emitUncheck,
|
|
@@ -121,12 +116,12 @@ export const emitters: Record<string, ProcessedCommandEmitter> = {
|
|
|
121
116
|
waitForElementNotEditable: emitWaitForElementNotEditable,
|
|
122
117
|
waitForElementNotPresent: emitWaitForElementNotPresent,
|
|
123
118
|
waitForElementNotVisible: emitWaitForElementNotVisible,
|
|
124
|
-
|
|
119
|
+
answerPrompt: emitAnswerOnNextPrompt,
|
|
125
120
|
waitForText: emitWaitForText,
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
121
|
+
dismissConfirmation: emitChooseCancelOnNextConfirmation,
|
|
122
|
+
dismissPrompt: emitChooseCancelOnNextConfirmation,
|
|
123
|
+
acceptConfirmation: emitChooseOkOnNextConfirmation,
|
|
124
|
+
acceptAlert: emitChooseOkOnNextConfirmation,
|
|
130
125
|
while: emitControlFlowWhile,
|
|
131
126
|
}
|
|
132
127
|
|
|
@@ -140,10 +135,17 @@ function emit(command: CommandShape, context: EmitterContext) {
|
|
|
140
135
|
return exporter.emit.command(command, emitters[command.command], {
|
|
141
136
|
context,
|
|
142
137
|
variableLookup,
|
|
138
|
+
variableInString,
|
|
143
139
|
emitNewWindowHandling,
|
|
144
140
|
})
|
|
145
141
|
}
|
|
146
142
|
|
|
143
|
+
// How a variable is joined with a string literal, e.g. "Hi " + name
|
|
144
|
+
const variableInString = {
|
|
145
|
+
quotes: ['"', "'"],
|
|
146
|
+
toString: (lookup: string) => `str(${lookup})`,
|
|
147
|
+
}
|
|
148
|
+
|
|
147
149
|
function variableLookup(varName: string) {
|
|
148
150
|
return `self.vars["${varName}"]`
|
|
149
151
|
}
|
|
@@ -261,9 +263,17 @@ function generateScriptArguments(script: ScriptShape) {
|
|
|
261
263
|
.join(',')}`
|
|
262
264
|
}
|
|
263
265
|
|
|
264
|
-
|
|
266
|
+
// The name of the counter of a loop, unique in a test
|
|
267
|
+
const loopCounter = (context?: EmitterContext) => `loop${context?.loopId ?? 1}`
|
|
268
|
+
|
|
269
|
+
function emitControlFlowDo(
|
|
270
|
+
_target: string,
|
|
271
|
+
_value: string,
|
|
272
|
+
context: EmitterContext
|
|
273
|
+
) {
|
|
265
274
|
return Promise.resolve({
|
|
266
275
|
commands: [
|
|
276
|
+
{ level: 0, statement: `${loopCounter(context)} = 0` },
|
|
267
277
|
{ level: 0, statement: 'condition = True' },
|
|
268
278
|
{ level: 0, statement: 'while condition:' },
|
|
269
279
|
],
|
|
@@ -331,9 +341,21 @@ function emitControlFlowForEach(
|
|
|
331
341
|
})
|
|
332
342
|
}
|
|
333
343
|
|
|
334
|
-
function emitControlFlowRepeatIf(
|
|
344
|
+
function emitControlFlowRepeatIf(
|
|
345
|
+
script: ScriptShape,
|
|
346
|
+
value: string,
|
|
347
|
+
context: EmitterContext
|
|
348
|
+
) {
|
|
349
|
+
const loop = loopCounter(context)
|
|
335
350
|
return Promise.resolve({
|
|
336
351
|
commands: [
|
|
352
|
+
{ level: 0, statement: `${loop} += 1` },
|
|
353
|
+
{
|
|
354
|
+
level: 0,
|
|
355
|
+
statement: `if ${loop} > ${exporter.parsers.loopLimit(
|
|
356
|
+
value
|
|
357
|
+
)}: raise Exception("${exporter.parsers.loopLimitMessage}")`,
|
|
358
|
+
},
|
|
337
359
|
{
|
|
338
360
|
level: 0,
|
|
339
361
|
statement: `condition = ${generateExpressionScript(script)}`,
|
|
@@ -343,17 +365,47 @@ function emitControlFlowRepeatIf(script: ScriptShape) {
|
|
|
343
365
|
})
|
|
344
366
|
}
|
|
345
367
|
|
|
346
|
-
function emitControlFlowTimes(
|
|
347
|
-
|
|
348
|
-
|
|
368
|
+
function emitControlFlowTimes(
|
|
369
|
+
target: string,
|
|
370
|
+
value: string,
|
|
371
|
+
context: EmitterContext
|
|
372
|
+
) {
|
|
373
|
+
const loop = loopCounter(context)
|
|
374
|
+
const count = exporter.parsers.loopCount(
|
|
375
|
+
target,
|
|
376
|
+
(count) => `int(float(${count}) // 1)`
|
|
377
|
+
)
|
|
378
|
+
return Promise.resolve({
|
|
379
|
+
commands: [
|
|
380
|
+
{ level: 0, statement: `for ${loop} in range(0, ${count}):` },
|
|
381
|
+
{
|
|
382
|
+
level: 1,
|
|
383
|
+
statement: `if ${loop} >= ${exporter.parsers.loopLimit(
|
|
384
|
+
value
|
|
385
|
+
)}: raise Exception("${exporter.parsers.loopLimitMessage}")`,
|
|
386
|
+
},
|
|
387
|
+
],
|
|
388
|
+
})
|
|
349
389
|
}
|
|
350
390
|
|
|
351
|
-
function emitControlFlowWhile(
|
|
391
|
+
function emitControlFlowWhile(
|
|
392
|
+
script: ScriptShape,
|
|
393
|
+
value: string,
|
|
394
|
+
context: EmitterContext
|
|
395
|
+
) {
|
|
396
|
+
const loop = loopCounter(context)
|
|
352
397
|
return Promise.resolve({
|
|
353
398
|
commands: [
|
|
399
|
+
{ level: 0, statement: `${loop} = 0` },
|
|
354
400
|
{ level: 0, statement: `while ${generateExpressionScript(script)}:` },
|
|
401
|
+
{ level: 1, statement: `${loop} += 1` },
|
|
402
|
+
{
|
|
403
|
+
level: 1,
|
|
404
|
+
statement: `if ${loop} > ${exporter.parsers.loopLimit(
|
|
405
|
+
value
|
|
406
|
+
)}: raise Exception("${exporter.parsers.loopLimitMessage}")`,
|
|
407
|
+
},
|
|
355
408
|
],
|
|
356
|
-
endingLevelAdjustment: 1,
|
|
357
409
|
})
|
|
358
410
|
}
|
|
359
411
|
|
|
@@ -394,21 +446,8 @@ async function emitDragAndDrop(dragged: string, dropped: string) {
|
|
|
394
446
|
return Promise.resolve({ commands })
|
|
395
447
|
}
|
|
396
448
|
|
|
397
|
-
function translateToPythonString(str: string) {
|
|
398
|
-
const regExp = /self.vars\["\w+"]/
|
|
399
|
-
const vars = str.match(regExp)
|
|
400
|
-
|
|
401
|
-
if (vars && vars.length > 0) {
|
|
402
|
-
const fmtStr = str.replace(regExp, '{}')
|
|
403
|
-
return `"${fmtStr}".format(${vars.join(', ')})`
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
return `"${str}"`
|
|
407
|
-
}
|
|
408
|
-
|
|
409
449
|
async function emitEcho(message: string) {
|
|
410
|
-
|
|
411
|
-
return Promise.resolve(`print(${_message})`)
|
|
450
|
+
return Promise.resolve(`print("${message}")`)
|
|
412
451
|
}
|
|
413
452
|
|
|
414
453
|
async function emitEditContent(locator: string, content: string) {
|
|
@@ -515,8 +554,22 @@ async function emitPause(time: number) {
|
|
|
515
554
|
return Promise.resolve({ commands })
|
|
516
555
|
}
|
|
517
556
|
|
|
518
|
-
async function emitRun(
|
|
519
|
-
|
|
557
|
+
async function emitRun(
|
|
558
|
+
testName: string,
|
|
559
|
+
_value: string,
|
|
560
|
+
context: EmitterContext
|
|
561
|
+
) {
|
|
562
|
+
// The test to run is only known during playback
|
|
563
|
+
if (hasVariable(testName)) {
|
|
564
|
+
return Promise.resolve(
|
|
565
|
+
`${context.commentPrefix} Cannot export run with a test name from a variable: ${testName}`
|
|
566
|
+
)
|
|
567
|
+
}
|
|
568
|
+
return Promise.resolve(
|
|
569
|
+
`self.${exporter.parsers.uncapitalize(
|
|
570
|
+
exporter.parsers.sanitizeName(testName)
|
|
571
|
+
)}()`
|
|
572
|
+
)
|
|
520
573
|
}
|
|
521
574
|
|
|
522
575
|
async function emitRunScript(script: ScriptShape) {
|
|
@@ -616,9 +669,7 @@ function generateSendKeysInput(value: string | string[]) {
|
|
|
616
669
|
if (typeof value === 'object') {
|
|
617
670
|
return value
|
|
618
671
|
.map((s) => {
|
|
619
|
-
if (s.startsWith('
|
|
620
|
-
return s
|
|
621
|
-
} else if (s.startsWith('Key[')) {
|
|
672
|
+
if (s.startsWith('Key[')) {
|
|
622
673
|
const key = s.match(/\['(.*)'\]/)?.[1]
|
|
623
674
|
return `Keys.${key}`
|
|
624
675
|
} else {
|
|
@@ -704,12 +755,6 @@ async function emitStoreXpathCount(locator: string, varName: string) {
|
|
|
704
755
|
return Promise.resolve(variableSetter(varName, result))
|
|
705
756
|
}
|
|
706
757
|
|
|
707
|
-
async function emitSubmit(_locator: string) {
|
|
708
|
-
return Promise.resolve(
|
|
709
|
-
`raise Exception("'submit' is not a supported command in Selenium WebDriver. Please re-record the step in the IDE.")`
|
|
710
|
-
)
|
|
711
|
-
}
|
|
712
|
-
|
|
713
758
|
async function emitType(target: string, value: string) {
|
|
714
759
|
return Promise.resolve(
|
|
715
760
|
`self.driver.find_element(${await location.emit(
|
|
@@ -812,7 +857,7 @@ async function emitVerifyNotSelectedValue(
|
|
|
812
857
|
},
|
|
813
858
|
{
|
|
814
859
|
level: 0,
|
|
815
|
-
statement: `assert value != "${
|
|
860
|
+
statement: `assert value != "${expectedValue}"`,
|
|
816
861
|
},
|
|
817
862
|
]
|
|
818
863
|
return Promise.resolve({ commands })
|
|
@@ -826,7 +871,7 @@ async function emitVerifyNotText(locator: string, text: string) {
|
|
|
826
871
|
locator
|
|
827
872
|
)}).text`,
|
|
828
873
|
},
|
|
829
|
-
{ level: 0, statement: `assert text != "${
|
|
874
|
+
{ level: 0, statement: `assert text != "${text}"` },
|
|
830
875
|
]
|
|
831
876
|
return Promise.resolve({ commands })
|
|
832
877
|
}
|
|
@@ -860,7 +905,7 @@ async function emitVerifyText(locator: string, text: string) {
|
|
|
860
905
|
level: 0,
|
|
861
906
|
statement: `assert self.driver.find_element(${await location.emit(
|
|
862
907
|
locator
|
|
863
|
-
)}).text == "${
|
|
908
|
+
)}).text == "${text}"`,
|
|
864
909
|
},
|
|
865
910
|
]
|
|
866
911
|
return Promise.resolve({ commands })
|
package/src/hook.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// KIND, either express or implied. See the License for the specific language governing permissions and limitations
|
|
15
15
|
// under the License.
|
|
16
16
|
|
|
17
|
-
import { HookFunctionInputs } from
|
|
17
|
+
import { HookFunctionInputs } from 'side-code-export'
|
|
18
18
|
|
|
19
19
|
const emitters = {
|
|
20
20
|
afterAll,
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,9 @@ export const opts: LanguageEmitterOpts = {
|
|
|
37
37
|
commandPrefixPadding: ' ',
|
|
38
38
|
terminatingKeyword: '',
|
|
39
39
|
commentPrefix: '#',
|
|
40
|
+
// A backslash before a backtick isn't a valid escape
|
|
41
|
+
escapedQuotes: `"'`,
|
|
42
|
+
emptyBlockStatement: 'pass',
|
|
40
43
|
// Create generators for dynamic string creation of primary entities (e.g., filename, methods, test, and suite)
|
|
41
44
|
generateTestDeclaration: function generateTestDeclaration(name) {
|
|
42
45
|
return `def test_${exporter.parsers.uncapitalize(
|
package/src/selection.ts
CHANGED
|
@@ -41,9 +41,6 @@ function emitValue(value: string) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function emitLabel(label: string) {
|
|
44
|
-
if (label.startsWith('self.vars[')) {
|
|
45
|
-
return Promise.resolve(`By.XPATH, "//option[. = '{}']".format(${label})`)
|
|
46
|
-
}
|
|
47
44
|
return Promise.resolve(`By.XPATH, "//option[. = '${label}']"`)
|
|
48
45
|
}
|
|
49
46
|
|