Skip to content

V3 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 12, 2019
Merged

V3 #9

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v3.13.0
- Control flow: Added optional loop limit override to `repeat if`
- Control flow: Excuded `for each` from implicit retry limit
- Runner: Fixed type checking bug for WebElements
- Plugins: Added support to open the IDE and load projects (PR #804)
- Code export: Added missing support for command registration to side-model (fixes broken code export for plugins)
- Variables: Added improved property access on variables (PR #808)

## v3.12.3
- Control flow: fix for off-by-one error in nested forEach command blocks

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"packages": [
"packages/*"
],
"version": "3.12.3",
"version": "3.13.0",
"npmClient": "yarn"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"postinstall": "lerna bootstrap",
"watch": "lerna run --no-bail --parallel watch",
"release-prep": "yarn && peru sync && yarn test && env NODE_ENV=staging yarn build:ext && yarn test:ext && yarn lint",
"preinstall": "node ./scripts/check-yarn.js",
"postpublish": "yarn build:ext:prod && npx ./gh-release.js"
},
"jest": {
Expand Down
4 changes: 2 additions & 2 deletions packages/code-export-java-junit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-export-java-junit",
"version": "3.12.2",
"version": "3.13.0",
"description": "Export Selenium IDE project contents to Java JUnit",
"repository": "https://github.com/SeleniumHQ/selenium-ide",
"keywords": [
Expand All @@ -21,6 +21,6 @@
"@babel/preset-env": "^7.4.5"
},
"dependencies": {
"@seleniumhq/side-utils": "^3.12.2"
"@seleniumhq/side-utils": "^3.13.0"
}
}
4 changes: 2 additions & 2 deletions packages/code-export-javascript-mocha/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-export-javascript-mocha",
"version": "3.12.2",
"version": "3.13.0",
"description": "Export Selenium IDE project contents to JavaScript Mocha",
"repository": "https://github.com/SeleniumHQ/selenium-ide",
"keywords": [
Expand All @@ -21,6 +21,6 @@
"@babel/preset-env": "^7.4.5"
},
"dependencies": {
"@seleniumhq/side-utils": "^3.12.2"
"@seleniumhq/side-utils": "^3.13.0"
}
}
4 changes: 2 additions & 2 deletions packages/code-export-python-pytest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-export-python-pytest",
"version": "3.12.2",
"version": "3.13.0",
"description": "Export Selenium IDE project contents to Python pytest",
"repository": "https://github.com/SeleniumHQ/selenium-ide",
"keywords": [
Expand All @@ -21,6 +21,6 @@
"@babel/preset-env": "^7.4.5"
},
"dependencies": {
"@seleniumhq/side-utils": "^3.12.2"
"@seleniumhq/side-utils": "^3.13.0"
}
}
8 changes: 4 additions & 4 deletions packages/code-export/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "code-export",
"version": "3.12.2",
"version": "3.13.0",
"description": "Selenium IDE code export",
"repository": "https://github.com/SeleniumHQ/selenium-ide",
"keywords": [
Expand All @@ -20,8 +20,8 @@
"@babel/preset-env": "^7.4.5"
},
"dependencies": {
"code-export-java-junit": "^3.12.2",
"code-export-javascript-mocha": "^3.12.2",
"code-export-python-pytest": "^3.12.2"
"code-export-java-junit": "^3.13.0",
"code-export-javascript-mocha": "^3.13.0",
"code-export-python-pytest": "^3.13.0"
}
}
10 changes: 5 additions & 5 deletions packages/selenium-ide/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "selenium-ide-extension",
"version": "3.12.3",
"version": "3.13.0",
"description": "An integrated development environment for Selenium scripts",
"license": "Apache-2.0",
"private": true,
Expand Down Expand Up @@ -47,11 +47,11 @@
},
"dependencies": {
"@medv/finder": "^1.1.1",
"@seleniumhq/side-model": "^3.12.2",
"@seleniumhq/side-utils": "^3.12.2",
"@seleniumhq/side-model": "^3.13.0",
"@seleniumhq/side-utils": "^3.13.0",
"browser-webdriver": "^3.12.2",
"classnames": "^2.2.5",
"code-export": "^3.12.2",
"code-export": "^3.13.0",
"fuse.js": "^3.3.0",
"google-closure-library": "^20170521.0.0",
"js-beautify": "^1.7.5",
Expand All @@ -78,7 +78,7 @@
"react-transition-group": "^2.2.1",
"resolve-url": "^0.2.1",
"scroll-into-view-if-needed": "2",
"selianize": "^3.12.2",
"selianize": "^3.13.0",
"string-natural-compare": "^2.0.2",
"styled-components": "^2.1.2",
"ua-parser-js": "^0.7.17",
Expand Down
2 changes: 1 addition & 1 deletion packages/selenium-ide/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ router.use(undefined, apiv1)

export default function(message, _backgroundPage, sendResponse) {
// The sender is always the background page since he is the one listening to the event
// message.id is the external extension id
// message.sender is the external extension id
if (message.uri) {
router
.run(message)
Expand Down
4 changes: 2 additions & 2 deletions packages/selenium-ide/src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"description": "Selenium Record and Playback tool for ease of getting acquainted with Selenium WebDriver.",
"manifest_version": 2,
"name": "Selenium IDE",
"version": "3.12.3",
"version_name": "3.12.3",
"version": "3.13.0",
"version_name": "3.13.0",
"homepage_url": "https://github.com/SeleniumHQ/selenium-ide",
"icons": {
"16": "icons/icon16.png",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ describe('Command Node', () => {
node.timesVisited = 5
expect(node._isRetryLimit()).toBeTruthy()
})
it('retry limit ignored for forEach', () => {
const command = new Command(
undefined,
ControlFlowCommandNames.forEach,
'',
''
)
const node = new CommandNode(command)
node.timesVisited = 1000
expect(node._isRetryLimit()).toBeFalsy()
})
it('execute resolves with an error message when too many retries attempted in a loop', () => {
const command = new Command(undefined, ControlFlowCommandNames.while, '', 2)
const node = new CommandNode(command)
Expand Down
2 changes: 2 additions & 0 deletions packages/selenium-ide/src/neo/models/Command/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
Commands as _Commands,
ArgTypes as _ArgTypes,
TargetTypes,
registerCommand,
} from '@seleniumhq/side-model'
const EventEmitter = require('events')
import { mergeEventEmitter } from '../../../common/events'
Expand Down Expand Up @@ -259,6 +260,7 @@ class CommandList {
throw new Error(`Command with the id ${id} already exists`)
} else {
this.list.set(id, name)
registerCommand(id, name)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ export class CommandNode {
}

_isRetryLimit() {
if (ControlFlowCommandChecks.isLoop(this.command)) {
if (
ControlFlowCommandChecks.isLoop(this.command) &&
this.command.command !== 'forEach'
) {
let limit = 1000
let value = Math.floor(+this.command.value)
if (this.command.value && !isNaN(value)) {
Expand Down
68 changes: 68 additions & 0 deletions packages/selenium-ide/src/neo/stores/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,73 @@ export default function seed(store, numberOfSuites = 0) {
)
storeJson.createCommand(undefined, 'assert', 'result', 'true')

const accessVariable = store.createTestCase('access variable')
accessVariable.createCommand(
undefined,
'storeJson',
`{"a": [{"b":0}, {"b":1}]}`,
'blah'
)
accessVariable.createCommand(undefined, 'store', '${blah.a[0].b}', 'result')
accessVariable.createCommand(undefined, 'assert', 'result', '0')

const accessVariableAssert = store.createTestCase('access variable assert')
accessVariableAssert.createCommand(undefined, 'storeJson', `{"a":0}`, 'blah')
accessVariableAssert.createCommand(undefined, 'assert', 'blah.a', '0')

const accessVariableArray = store.createTestCase('access variable array')
accessVariableArray.createCommand(
undefined,
'storeJson',
`[{"a":0}, {"a":1}]`,
'blah'
)
accessVariableArray.createCommand(undefined, 'assert', 'blah[1].a', '1')

const accessVariableNestedJson = store.createTestCase(
'access variable nested json'
)
accessVariableNestedJson.createCommand(
undefined,
'storeJson',
`[{"a":[{"b":0}, {"b":{"c":1}}]}, {"a":2}]`,
'blah'
)
accessVariableNestedJson.createCommand(
undefined,
'assert',
'blah[0].a[1].b.c',
'1'
)

const accessVariableForEach = store.createTestCase('access variable for each')
accessVariableForEach.createCommand(
undefined,
'executeScript',
'return 0',
'result'
)
accessVariableForEach.createCommand(
undefined,
'storeJson',
`{"a":[{"b":0}, {"b":1}, {"b":2}]}`,
'blah'
)
accessVariableForEach.createCommand(
undefined,
'forEach',
'blah.a',
'iterator'
)
accessVariableForEach.createCommand(
undefined,
'executeScript',
'return ${result} + ${iterator.b}',
'result'
)
accessVariableForEach.createCommand(undefined, 'end', '', '')
accessVariableForEach.createCommand(undefined, 'assert', 'result', '3')

const suiteAll = store.createSuite('all tests')
store.tests.forEach(function(test) {
suiteAll.addTestCase(test)
Expand All @@ -679,6 +746,7 @@ export default function seed(store, numberOfSuites = 0) {
smokeSuite.addTestCase(checkTest)
smokeSuite.addTestCase(clickTest)
smokeSuite.addTestCase(clickAtTest)
smokeSuite.addTestCase(accessVariable)
smokeSuite.addTestCase(executeScriptTest)
smokeSuite.addTestCase(executeScriptArray)
smokeSuite.addTestCase(executeScriptPrimitives)
Expand Down
64 changes: 64 additions & 0 deletions packages/selenium-ide/src/neo/stores/view/Variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,38 @@ export default class Variables {

@action.bound
get(key) {
if (this.storedVars.get(key) == undefined) {
if (/(\.)/.exec(key)) {
//a.b , a[0].b, a.b[3].c
let propertyAccess = /([^.\n]+)\.(.*)/.exec(key)
if (this.storedVars.has(propertyAccess[1])) {
//a.b, a.b[0].c
let r3 = getPropertyValue(
this.storedVars.get(propertyAccess[1]),
propertyAccess[2]
)
return r3
} else if (/([^.\n]+)\[(\d*)\]/.exec(propertyAccess[1])) {
//a[0].b
let arrayAccess = /([^.\n]+)\[(\d*)\]/.exec(propertyAccess[1])
if (this.storedVars.has(arrayAccess[1])) {
let r3 = getPropertyValue(
this.storedVars.get(arrayAccess[1])[arrayAccess[2]],
propertyAccess[2]
)
return r3
}
}
} else if (/([^.\n]+)\[(\d*)\]/.exec(key)) {
//a[0]
let arrayAccess = /([^.\n]+)\[(\d*)\]/.exec(key)
if (this.storedVars.has(arrayAccess[1])) {
let r3 = this.storedVars.get(arrayAccess[1])
return r3[arrayAccess[2]]
}
}
return this.storedVars.get(key)
}
return this.storedVars.get(key)
}

Expand All @@ -33,16 +65,48 @@ export default class Variables {

@action.bound
has(key) {
if (this.storedVars.has(key) == false) {
if (/(\.)/.exec(key)) {
//a.b or a[0].b or a.b[0].c
let propertyAccess = /([^.\n]+)\.(.*)/.exec(key)
if (
this.storedVars.has(propertyAccess[1]) == false &&
/([^.\n]+)\[(\d*)\]/.exec(propertyAccess[1])
) {
//arr[0].a
let arrayAccess = /([^.\n]+)\[(\d*)\]/.exec(propertyAccess[1])
return this.storedVars.has(arrayAccess[1])
} else return this.storedVars.has(propertyAccess[1])
} else if (/([^.\n]+)\[(\d*)\]/.exec(key)) {
// a[0]
let arrayAccess = /([^.\n]+)\[(\d*)\]/.exec(key)
return this.storedVars.has(arrayAccess[1])
}
}
return this.storedVars.has(key)
}

@action.bound
delete(key) {
if (this.storedVars.has(key)) this.storedVars.delete(key)
else if (/(\.)/.exec(key)) {
let propertyAccess = /([^.]+)\.(.*)/.exec(key)
this.storedVars.delete(propertyAccess[1])
}
}

@action.bound
clear() {
this.storedVars.clear()
}
}

function getPropertyValue(obj1, dataToRetrieve) {
return dataToRetrieve.split('.').reduce(function(o, k) {
if (/([^.\n]+)\[(\d*)\]/.exec(k)) {
let arr = /([^.\n]+)\[(\d*)\]/.exec(k)
return o && o[arr[1]][arr[2]]
}
return o && o[k]
}, obj1)
}
6 changes: 3 additions & 3 deletions packages/selenium-side-runner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "selenium-side-runner",
"version": "3.12.2",
"version": "3.13.0",
"description": "Run Selenium IDE projects in cli",
"repository": "https://github.com/SeleniumHQ/selenium-ide",
"scripts": {
Expand Down Expand Up @@ -33,12 +33,12 @@
"glob": "^7.1.2",
"global-npm": "^0.3.0",
"jest-cli": "24.7.1",
"jest-environment-selenium": "2.1.1",
"jest-environment-selenium": "2.1.2",
"js-beautify": "^1.7.5",
"js-yaml": "^3.13.1",
"rimraf": "^2.6.2",
"selenium-webdriver": "4.0.0-alpha.4",
"selianize": "^3.12.2",
"selianize": "^3.13.0",
"semver": "^5.5.1",
"winston": "^2.4.0"
},
Expand Down
Loading