@seleniumhq/code-export-javascript-mocha 3.16.1 → 3.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__test__/src/__snapshots__/command.spec.js.snap +3 -1
- package/__test__/src/__snapshots__/index.spec.js.snap +21 -8
- package/__test__/src/command.spec.js +9 -1
- package/__test__/src/index.spec.js +12 -3
- package/package.json +3 -3
- package/src/command.js +12 -2
- package/src/hook.js +1 -1
- package/src/index.js +6 -1
- package/src/location.js +1 -1
- package/src/selection.js +1 -1
- package/dist/command.js +0 -953
- package/dist/hook.js +0 -173
- package/dist/hooks/afterAll.js +0 -48
- package/dist/hooks/afterEach.js +0 -49
- package/dist/hooks/beforeAll.js +0 -48
- package/dist/hooks/beforeEach.js +0 -50
- package/dist/hooks/declareDependencies.js +0 -66
- package/dist/hooks/declareMethods.js +0 -53
- package/dist/hooks/declareVariables.js +0 -48
- package/dist/hooks/inEach.js +0 -42
- package/dist/hooks/inEachBegin.js +0 -42
- package/dist/hooks/inEachEnd.js +0 -42
- package/dist/hooks/index.js +0 -61
- package/dist/index.js +0 -136
- package/dist/location.js +0 -68
- package/dist/parsers.js +0 -31
- package/dist/selection.js +0 -57
- package/yarn-error.log +0 -2196
|
@@ -303,7 +303,7 @@ exports[`command code emitter should emit \`send keys\` command with a variable
|
|
|
303
303
|
|
|
304
304
|
exports[`command code emitter should emit \`set speed\` 1`] = `"console.log(\\"\`set speed\` is a no-op in code export, use \`pause\` instead\\")"`;
|
|
305
305
|
|
|
306
|
-
exports[`command code emitter should emit \`setWindowSize\` 1`] = `"await driver.manage().window().setRect(1440, 1177)"`;
|
|
306
|
+
exports[`command code emitter should emit \`setWindowSize\` 1`] = `"await driver.manage().window().setRect({ width: 1440, height: 1177 })"`;
|
|
307
307
|
|
|
308
308
|
exports[`command code emitter should emit \`store attribute\` command 1`] = `
|
|
309
309
|
"{
|
|
@@ -420,6 +420,8 @@ exports[`command code emitter should emit \`waitForElementPresent\` command 1`]
|
|
|
420
420
|
|
|
421
421
|
exports[`command code emitter should emit \`waitForElementVisible\` command 1`] = `"await driver.wait(until.elementIsVisible(await driver.findElement(By.css(\\"#blah\\"))), 5000)"`;
|
|
422
422
|
|
|
423
|
+
exports[`command code emitter should emit \`waitForText\` command 1`] = `"await driver.wait(until.elementTextIs(await driver.findElement(By.css(\\"#blah\\")), 'text'), 30000)"`;
|
|
424
|
+
|
|
423
425
|
exports[`command code emitter should emit \`while\` command 1`] = `"while(!!await driver.executeScript(\\"return (true)\\")) {"`;
|
|
424
426
|
|
|
425
427
|
exports[`command code emitter should emit new window handling, if command opens a new window 1`] = `
|
|
@@ -18,7 +18,7 @@ describe('login', function() {
|
|
|
18
18
|
})
|
|
19
19
|
it('valid credentials', async function() {
|
|
20
20
|
await driver.get(\\"http://the-internet.herokuapp.com/login\\")
|
|
21
|
-
await driver.manage().window().setRect(1440, 1177)
|
|
21
|
+
await driver.manage().window().setRect({ width: 1440, height: 1177 })
|
|
22
22
|
await driver.findElement(By.id(\\"username\\")).sendKeys(\\"tomsmith\\")
|
|
23
23
|
await driver.findElement(By.id(\\"password\\")).sendKeys(\\"SuperSecretPassword!\\")
|
|
24
24
|
await driver.findElement(By.css(\\"#login button\\")).click()
|
|
@@ -26,7 +26,7 @@ describe('login', function() {
|
|
|
26
26
|
})
|
|
27
27
|
it('invalid credentials', async function() {
|
|
28
28
|
await driver.get(\\"http://the-internet.herokuapp.com/login\\")
|
|
29
|
-
await driver.manage().window().setRect(1440, 1177)
|
|
29
|
+
await driver.manage().window().setRect({ width: 1440, height: 1177 })
|
|
30
30
|
await driver.findElement(By.id(\\"username\\")).sendKeys(\\"blah\\")
|
|
31
31
|
await driver.findElement(By.id(\\"password\\")).sendKeys(\\"blah\\")
|
|
32
32
|
await driver.findElement(By.css(\\"#login button\\")).click()
|
|
@@ -116,7 +116,7 @@ exports[`Code Export JavaScript Mocha should export a suite with a reused test m
|
|
|
116
116
|
const { Builder, By, Key, until } = require('selenium-webdriver')
|
|
117
117
|
const assert = require('assert')
|
|
118
118
|
|
|
119
|
-
describe('
|
|
119
|
+
describe('Reused methods', function() {
|
|
120
120
|
this.timeout(30000)
|
|
121
121
|
let driver
|
|
122
122
|
let vars
|
|
@@ -132,7 +132,12 @@ describe('login', function() {
|
|
|
132
132
|
await driver.findElement(By.linkText(\\"Form Authentication\\")).click()
|
|
133
133
|
await driver.findElement(By.id(\\"username\\")).sendKeys(vars[\\"username\\"])
|
|
134
134
|
await driver.findElement(By.id(\\"password\\")).sendKeys(vars[\\"password\\"])
|
|
135
|
-
await driver.
|
|
135
|
+
if (!!await driver.executeScript(\\"return (true)\\")) {
|
|
136
|
+
await driver.findElement(By.css(\\".fa\\")).click()
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function tinymethod() {
|
|
140
|
+
vars[\\"value\\"] = \\"field\\"
|
|
136
141
|
}
|
|
137
142
|
it('invalid credentials', async function() {
|
|
138
143
|
vars[\\"username\\"] = \\"blah\\"
|
|
@@ -144,6 +149,12 @@ describe('login', function() {
|
|
|
144
149
|
vars[\\"password\\"] = \\"SuperSecretPassword!\\"
|
|
145
150
|
login()
|
|
146
151
|
})
|
|
152
|
+
it('two methods', async function() {
|
|
153
|
+
vars[\\"username\\"] = \\"blah\\"
|
|
154
|
+
vars[\\"password\\"] = \\"blah\\"
|
|
155
|
+
login()
|
|
156
|
+
tinymethod()
|
|
157
|
+
})
|
|
147
158
|
})
|
|
148
159
|
"
|
|
149
160
|
`;
|
|
@@ -254,7 +265,7 @@ describe('login', function() {
|
|
|
254
265
|
})
|
|
255
266
|
it('login', async function() {
|
|
256
267
|
await driver.get(\\"http://the-internet.herokuapp.com/login\\")
|
|
257
|
-
await driver.manage().window().setRect(1440, 1177)
|
|
268
|
+
await driver.manage().window().setRect({ width: 1440, height: 1177 })
|
|
258
269
|
await driver.findElement(By.id(\\"username\\")).sendKeys(\\"tomsmith\\")
|
|
259
270
|
await driver.findElement(By.id(\\"password\\")).sendKeys(\\"SuperSecretPassword!\\")
|
|
260
271
|
await driver.findElement(By.css(\\"#login button\\")).click()
|
|
@@ -285,7 +296,9 @@ describe('valid credentials', function() {
|
|
|
285
296
|
await driver.findElement(By.linkText(\\"Form Authentication\\")).click()
|
|
286
297
|
await driver.findElement(By.id(\\"username\\")).sendKeys(vars[\\"username\\"])
|
|
287
298
|
await driver.findElement(By.id(\\"password\\")).sendKeys(vars[\\"password\\"])
|
|
288
|
-
await driver.
|
|
299
|
+
if (!!await driver.executeScript(\\"return (true)\\")) {
|
|
300
|
+
await driver.findElement(By.css(\\".fa\\")).click()
|
|
301
|
+
}
|
|
289
302
|
}
|
|
290
303
|
it('valid credentials', async function() {
|
|
291
304
|
vars[\\"username\\"] = \\"tomsmith\\"
|
|
@@ -323,7 +336,7 @@ describe('select window', function() {
|
|
|
323
336
|
}
|
|
324
337
|
it('select window', async function() {
|
|
325
338
|
await driver.get(\\"http://the-internet.herokuapp.com/\\")
|
|
326
|
-
await driver.manage().window().setRect(1260, 1027)
|
|
339
|
+
await driver.manage().window().setRect({ width: 1260, height: 1027 })
|
|
327
340
|
await driver.findElement(By.linkText(\\"Multiple Windows\\")).click()
|
|
328
341
|
vars[\\"windowHandles\\"] = await driver.getAllWindowHandles()
|
|
329
342
|
await driver.findElement(By.linkText(\\"Click Here\\")).click()
|
|
@@ -356,7 +369,7 @@ describe('login', function() {
|
|
|
356
369
|
})
|
|
357
370
|
it('login', async function() {
|
|
358
371
|
await driver.get(\\"http://the-internet.herokuapp.com/login\\")
|
|
359
|
-
await driver.manage().window().setRect(1440, 1177)
|
|
372
|
+
await driver.manage().window().setRect({ width: 1440, height: 1177 })
|
|
360
373
|
await driver.findElement(By.id(\\"username\\")).sendKeys(\\"tomsmith\\")
|
|
361
374
|
await driver.findElement(By.id(\\"password\\")).sendKeys(\\"SuperSecretPassword!\\")
|
|
362
375
|
await driver.findElement(By.css(\\"#login button\\")).click()
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
ControlFlowCommandNames,
|
|
22
22
|
} from '../../../selenium-ide/src/neo/models/Command'
|
|
23
23
|
import { opts } from '../../src/index'
|
|
24
|
-
import { codeExport as exporter } from '@seleniumhq/side-
|
|
24
|
+
import { codeExport as exporter } from '@seleniumhq/side-code-export'
|
|
25
25
|
|
|
26
26
|
const commandPrefixPadding = opts.commandPrefixPadding
|
|
27
27
|
|
|
@@ -838,6 +838,14 @@ describe('command code emitter', () => {
|
|
|
838
838
|
}
|
|
839
839
|
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
840
840
|
})
|
|
841
|
+
it('should emit `waitForText` command', () => {
|
|
842
|
+
const command = {
|
|
843
|
+
command: 'waitForText',
|
|
844
|
+
target: 'css=#blah',
|
|
845
|
+
value: 'text',
|
|
846
|
+
}
|
|
847
|
+
return expect(prettify(command)).resolves.toMatchSnapshot()
|
|
848
|
+
})
|
|
841
849
|
it('should emit `answer on visible prompt` command', () => {
|
|
842
850
|
const command = {
|
|
843
851
|
command: 'webdriverAnswerOnVisiblePrompt',
|
|
@@ -17,8 +17,14 @@
|
|
|
17
17
|
|
|
18
18
|
import fs from 'fs'
|
|
19
19
|
import path from 'path'
|
|
20
|
-
import
|
|
21
|
-
|
|
20
|
+
import codeExport, {
|
|
21
|
+
emitTest,
|
|
22
|
+
emitSuite,
|
|
23
|
+
_emitMethod,
|
|
24
|
+
_findTestByName,
|
|
25
|
+
} from '../../src'
|
|
26
|
+
import Command from '../../src/command'
|
|
27
|
+
import { project as projectProcessor } from '@seleniumhq/side-code-export'
|
|
22
28
|
|
|
23
29
|
function readFile(filename) {
|
|
24
30
|
return JSON.parse(
|
|
@@ -28,7 +34,7 @@ function readFile(filename) {
|
|
|
28
34
|
'..',
|
|
29
35
|
'..',
|
|
30
36
|
'..',
|
|
31
|
-
'side-
|
|
37
|
+
'side-code-export',
|
|
32
38
|
'__test__',
|
|
33
39
|
'test-files',
|
|
34
40
|
filename
|
|
@@ -132,6 +138,9 @@ describe('Code Export JavaScript Mocha', () => {
|
|
|
132
138
|
expect(results.body).toBeDefined()
|
|
133
139
|
expect(results.body).toMatchSnapshot()
|
|
134
140
|
})
|
|
141
|
+
it('should export the command emitter', () => {
|
|
142
|
+
expect(Command.emit).toStrictEqual(codeExport.emit.command)
|
|
143
|
+
})
|
|
135
144
|
})
|
|
136
145
|
|
|
137
146
|
function normalizeProject(project) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seleniumhq/code-export-javascript-mocha",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.4",
|
|
4
4
|
"description": "Export Selenium IDE project contents to JavaScript Mocha",
|
|
5
5
|
"repository": "https://github.com/SeleniumHQ/selenium-ide",
|
|
6
6
|
"keywords": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@babel/preset-env": "^7.4.5"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@seleniumhq/side-
|
|
24
|
+
"@seleniumhq/side-code-export": "^4.0.0-alpha.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "351d5762ed774d624831bf9a7a02ae4fb8e70ea9"
|
|
27
27
|
}
|
package/src/command.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
import { codeExport as exporter } from '@seleniumhq/side-
|
|
18
|
+
import { codeExport as exporter } from '@seleniumhq/side-code-export'
|
|
19
19
|
import location from './location'
|
|
20
20
|
import selection from './selection'
|
|
21
21
|
|
|
@@ -113,6 +113,7 @@ export const emitters = {
|
|
|
113
113
|
waitForElementNotPresent: emitWaitForElementNotPresent,
|
|
114
114
|
waitForElementNotVisible: emitWaitForElementNotVisible,
|
|
115
115
|
webdriverAnswerOnVisiblePrompt: emitAnswerOnNextPrompt,
|
|
116
|
+
waitForText: emitWaitForText,
|
|
116
117
|
webdriverChooseCancelOnVisibleConfirmation: emitChooseCancelOnNextConfirmation,
|
|
117
118
|
webdriverChooseCancelOnVisiblePrompt: emitChooseCancelOnNextConfirmation,
|
|
118
119
|
webdriverChooseOkOnVisibleConfirmation: emitChooseOkOnNextConfirmation,
|
|
@@ -541,7 +542,7 @@ async function emitRunScript(script) {
|
|
|
541
542
|
async function emitSetWindowSize(size) {
|
|
542
543
|
const [width, height] = size.split('x')
|
|
543
544
|
return Promise.resolve(
|
|
544
|
-
`await driver.manage().window().setRect(${width}, ${height})`
|
|
545
|
+
`await driver.manage().window().setRect({ width: ${width}, height: ${height} })`
|
|
545
546
|
)
|
|
546
547
|
}
|
|
547
548
|
|
|
@@ -974,6 +975,15 @@ async function emitWaitForElementNotEditable(locator, timeout) {
|
|
|
974
975
|
)
|
|
975
976
|
}
|
|
976
977
|
|
|
978
|
+
async function emitWaitForText(locator, text) {
|
|
979
|
+
const timeout = 30000
|
|
980
|
+
return Promise.resolve(
|
|
981
|
+
`await driver.wait(until.elementTextIs(await driver.findElement(${await location.emit(
|
|
982
|
+
locator
|
|
983
|
+
)}), '${text}'), ${Math.floor(timeout)})`
|
|
984
|
+
)
|
|
985
|
+
}
|
|
986
|
+
|
|
977
987
|
export default {
|
|
978
988
|
canEmit,
|
|
979
989
|
emit,
|
package/src/hook.js
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 { codeExport as exporter } from '@seleniumhq/side-
|
|
17
|
+
import { codeExport as exporter } from '@seleniumhq/side-code-export'
|
|
18
18
|
|
|
19
19
|
const emitters = {
|
|
20
20
|
afterAll,
|
package/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
import { codeExport as exporter } from '@seleniumhq/side-
|
|
18
|
+
import { codeExport as exporter } from '@seleniumhq/side-code-export'
|
|
19
19
|
import emitter from './command'
|
|
20
20
|
import location from './location'
|
|
21
21
|
import { generateHooks } from './hook'
|
|
@@ -61,6 +61,7 @@ export async function emitTest({
|
|
|
61
61
|
project,
|
|
62
62
|
enableOriginTracing,
|
|
63
63
|
beforeEachOptions,
|
|
64
|
+
enableDescriptionAsComment,
|
|
64
65
|
}) {
|
|
65
66
|
global.baseUrl = baseUrl
|
|
66
67
|
const testDeclaration = generateTestDeclaration(test.name)
|
|
@@ -68,6 +69,7 @@ export async function emitTest({
|
|
|
68
69
|
...opts,
|
|
69
70
|
testDeclaration,
|
|
70
71
|
enableOriginTracing,
|
|
72
|
+
enableDescriptionAsComment,
|
|
71
73
|
project,
|
|
72
74
|
})
|
|
73
75
|
const suiteName = test.name
|
|
@@ -93,11 +95,13 @@ export async function emitSuite({
|
|
|
93
95
|
project,
|
|
94
96
|
enableOriginTracing,
|
|
95
97
|
beforeEachOptions,
|
|
98
|
+
enableDescriptionAsComment,
|
|
96
99
|
}) {
|
|
97
100
|
global.baseUrl = baseUrl
|
|
98
101
|
const result = await exporter.emit.testsFromSuite(tests, suite, opts, {
|
|
99
102
|
enableOriginTracing,
|
|
100
103
|
generateTestDeclaration,
|
|
104
|
+
enableDescriptionAsComment,
|
|
101
105
|
project,
|
|
102
106
|
})
|
|
103
107
|
const suiteDeclaration = generateSuiteDeclaration(suite.name)
|
|
@@ -118,6 +122,7 @@ export default {
|
|
|
118
122
|
emit: {
|
|
119
123
|
test: emitTest,
|
|
120
124
|
suite: emitSuite,
|
|
125
|
+
command: emitter.emit,
|
|
121
126
|
locator: location.emit,
|
|
122
127
|
},
|
|
123
128
|
register: {
|
package/src/location.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
import { codeExport as exporter } from '@seleniumhq/side-
|
|
18
|
+
import { codeExport as exporter } from '@seleniumhq/side-code-export'
|
|
19
19
|
|
|
20
20
|
const emitters = {
|
|
21
21
|
id: emitId,
|
package/src/selection.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// specific language governing permissions and limitations
|
|
16
16
|
// under the License.
|
|
17
17
|
|
|
18
|
-
import { codeExport as exporter } from '@seleniumhq/side-
|
|
18
|
+
import { codeExport as exporter } from '@seleniumhq/side-code-export'
|
|
19
19
|
|
|
20
20
|
const emitters = {
|
|
21
21
|
id: emitId,
|