From 5d595cd4c58c504a4b0bc47d3d39c45c636c9c32 Mon Sep 17 00:00:00 2001 From: toddtarsi Date: Fri, 22 Nov 2024 06:58:19 -0600 Subject: [PATCH] minor fix, nothing to type for empty strings --- packages/browser-info/package.json | 2 +- .../code-export-csharp-commons/package.json | 4 +- .../code-export-csharp-nunit/package.json | 4 +- .../code-export-csharp-xunit/package.json | 6 +- packages/code-export-java-junit/package.json | 4 +- .../code-export-javascript-mocha/package.json | 4 +- .../code-export-python-pytest/package.json | 4 +- packages/code-export-ruby-rspec/package.json | 4 +- packages/get-driver/package.json | 2 +- packages/selenium-ide/package.json | 28 ++-- packages/side-api/package.json | 10 +- packages/side-code-export/package.json | 6 +- packages/side-commons/package.json | 2 +- packages/side-example-suite/package.json | 6 +- packages/side-migrate/package.json | 2 +- packages/side-model/package.json | 2 +- packages/side-runner/package.json | 6 +- packages/side-runtime/package.json | 16 +-- packages/side-runtime/src/webdriver.ts | 4 +- packages/side-test-metaparser/jest.config.js | 10 ++ packages/side-test-metaparser/package.json | 28 ++++ packages/side-test-metaparser/src/index.ts | 47 +++++++ .../side-test-metaparser/src/lang-example.ts | 110 +++++++++++++++ .../side-test-metaparser/src/parsers/click.ts | 0 .../src/parsers/comment.ts | 23 ++++ .../src/parsers/execute-script.ts | 0 .../src/parsers/find-element-locator.ts | 0 .../src/parsers/log-string-static.ts | 28 ++++ .../src/parsers/log-string-with-variables.ts | 0 .../src/parsers/select-element.ts | 0 .../src/parsers/send-keys.ts | 0 .../src/parsers/set-nested-variable.ts | 0 .../src/parsers/set-variable.ts | 0 .../src/parsers/wait-for-attribute.ts | 0 .../src/parsers/wait-for-text.ts | 0 .../src/parsers/wait-for-value.ts | 0 packages/side-test-metaparser/src/types.ts | 4 + packages/side-test-metaparser/tsconfig.json | 25 ++++ packages/side-testkit/package.json | 2 +- packages/webdriver-testkit/package.json | 10 +- pnpm-lock.yaml | 130 ++++++++++-------- tsconfig.json | 3 + 42 files changed, 418 insertions(+), 118 deletions(-) create mode 100644 packages/side-test-metaparser/jest.config.js create mode 100644 packages/side-test-metaparser/package.json create mode 100644 packages/side-test-metaparser/src/index.ts create mode 100644 packages/side-test-metaparser/src/lang-example.ts create mode 100644 packages/side-test-metaparser/src/parsers/click.ts create mode 100644 packages/side-test-metaparser/src/parsers/comment.ts create mode 100644 packages/side-test-metaparser/src/parsers/execute-script.ts create mode 100644 packages/side-test-metaparser/src/parsers/find-element-locator.ts create mode 100644 packages/side-test-metaparser/src/parsers/log-string-static.ts create mode 100644 packages/side-test-metaparser/src/parsers/log-string-with-variables.ts create mode 100644 packages/side-test-metaparser/src/parsers/select-element.ts create mode 100644 packages/side-test-metaparser/src/parsers/send-keys.ts create mode 100644 packages/side-test-metaparser/src/parsers/set-nested-variable.ts create mode 100644 packages/side-test-metaparser/src/parsers/set-variable.ts create mode 100644 packages/side-test-metaparser/src/parsers/wait-for-attribute.ts create mode 100644 packages/side-test-metaparser/src/parsers/wait-for-text.ts create mode 100644 packages/side-test-metaparser/src/parsers/wait-for-value.ts create mode 100644 packages/side-test-metaparser/src/types.ts create mode 100644 packages/side-test-metaparser/tsconfig.json diff --git a/packages/browser-info/package.json b/packages/browser-info/package.json index 0b0500e107..3a47c10ab0 100644 --- a/packages/browser-info/package.json +++ b/packages/browser-info/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/browser-info", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Get information about installed browsers", "author": "Tomer ", diff --git a/packages/code-export-csharp-commons/package.json b/packages/code-export-csharp-commons/package.json index 7873cd61aa..7300e25a54 100644 --- a/packages/code-export-csharp-commons/package.json +++ b/packages/code-export-csharp-commons/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/code-export-csharp-commons", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Commons for exporting Selenium IDE project contents to C#", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -21,6 +21,6 @@ "side-code-export": "^4.0.11" }, "devDependencies": { - "@seleniumhq/side-model": "4.0.12" + "@seleniumhq/side-model": "4.0.13" } } diff --git a/packages/code-export-csharp-nunit/package.json b/packages/code-export-csharp-nunit/package.json index ca62865b41..e565ce9948 100644 --- a/packages/code-export-csharp-nunit/package.json +++ b/packages/code-export-csharp-nunit/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/code-export-csharp-nunit", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Export Selenium IDE project contents to C# NUnit", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -18,7 +18,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "dependencies": { - "@seleniumhq/code-export-csharp-commons": "4.0.12", + "@seleniumhq/code-export-csharp-commons": "4.0.13", "side-code-export": "^4.0.11" }, "gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744" diff --git a/packages/code-export-csharp-xunit/package.json b/packages/code-export-csharp-xunit/package.json index 54cda7bb25..88a3acc7f5 100644 --- a/packages/code-export-csharp-xunit/package.json +++ b/packages/code-export-csharp-xunit/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/code-export-csharp-xunit", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Export Selenium IDE project contents to C# XUnit", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -18,11 +18,11 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "dependencies": { - "@seleniumhq/code-export-csharp-commons": "4.0.12", + "@seleniumhq/code-export-csharp-commons": "4.0.13", "side-code-export": "^4.0.11" }, "devDependencies": { - "@seleniumhq/side-model": "4.0.12" + "@seleniumhq/side-model": "4.0.13" }, "gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744" } diff --git a/packages/code-export-java-junit/package.json b/packages/code-export-java-junit/package.json index 55928b67f2..af158f72e2 100644 --- a/packages/code-export-java-junit/package.json +++ b/packages/code-export-java-junit/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/code-export-java-junit", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Export Selenium IDE project contents to Java JUnit", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -20,7 +20,7 @@ "side-code-export": "^4.0.11" }, "devDependencies": { - "@seleniumhq/side-model": "4.0.12" + "@seleniumhq/side-model": "4.0.13" }, "gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744" } diff --git a/packages/code-export-javascript-mocha/package.json b/packages/code-export-javascript-mocha/package.json index 07963eedb4..f1bdac572f 100644 --- a/packages/code-export-javascript-mocha/package.json +++ b/packages/code-export-javascript-mocha/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/code-export-javascript-mocha", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Export Selenium IDE project contents to JavaScript Mocha", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -20,7 +20,7 @@ "side-code-export": "^4.0.11" }, "devDependencies": { - "@seleniumhq/side-model": "4.0.12" + "@seleniumhq/side-model": "4.0.13" }, "gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744" } diff --git a/packages/code-export-python-pytest/package.json b/packages/code-export-python-pytest/package.json index 27e53e92d3..4864a5cd6f 100644 --- a/packages/code-export-python-pytest/package.json +++ b/packages/code-export-python-pytest/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/code-export-python-pytest", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Export Selenium IDE project contents to Python pytest", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -20,7 +20,7 @@ "side-code-export": "^4.0.11" }, "devDependencies": { - "@seleniumhq/side-model": "4.0.12" + "@seleniumhq/side-model": "4.0.13" }, "gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744" } diff --git a/packages/code-export-ruby-rspec/package.json b/packages/code-export-ruby-rspec/package.json index 3ac31de27c..0389b67674 100644 --- a/packages/code-export-ruby-rspec/package.json +++ b/packages/code-export-ruby-rspec/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/code-export-ruby-rspec", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Export Selenium IDE project contents to Ruby RSpec", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -20,7 +20,7 @@ "side-code-export": "^4.0.11" }, "devDependencies": { - "@seleniumhq/side-model": "4.0.12" + "@seleniumhq/side-model": "4.0.13" }, "gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744" } diff --git a/packages/get-driver/package.json b/packages/get-driver/package.json index a94b5b7329..346beec8e2 100644 --- a/packages/get-driver/package.json +++ b/packages/get-driver/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/get-driver", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Download browser drivers", "author": "Tomer ", diff --git a/packages/selenium-ide/package.json b/packages/selenium-ide/package.json index 95c4d8b6c2..b60d7a8655 100644 --- a/packages/selenium-ide/package.json +++ b/packages/selenium-ide/package.json @@ -118,17 +118,17 @@ "@fontsource/roboto": "^5.0.8", "@mui/icons-material": "^5.15.13", "@mui/material": "^5.15.13", - "@seleniumhq/code-export-csharp-nunit": "4.0.12", - "@seleniumhq/code-export-csharp-xunit": "4.0.12", - "@seleniumhq/code-export-java-junit": "4.0.12", - "@seleniumhq/code-export-javascript-mocha": "4.0.12", - "@seleniumhq/code-export-python-pytest": "4.0.12", - "@seleniumhq/code-export-ruby-rspec": "4.0.12", - "@seleniumhq/get-driver": "4.0.12", - "@seleniumhq/side-api": "4.0.12", - "@seleniumhq/side-commons": "4.0.12", - "@seleniumhq/side-model": "4.0.12", - "@seleniumhq/side-runtime": "4.0.12", + "@seleniumhq/code-export-csharp-nunit": "4.0.13", + "@seleniumhq/code-export-csharp-xunit": "4.0.13", + "@seleniumhq/code-export-java-junit": "4.0.13", + "@seleniumhq/code-export-javascript-mocha": "4.0.13", + "@seleniumhq/code-export-python-pytest": "4.0.13", + "@seleniumhq/code-export-ruby-rspec": "4.0.13", + "@seleniumhq/get-driver": "4.0.13", + "@seleniumhq/side-api": "4.0.13", + "@seleniumhq/side-commons": "4.0.13", + "@seleniumhq/side-model": "4.0.13", + "@seleniumhq/side-runtime": "4.0.13", "dnd-core": "^16.0.1", "electron-chromedriver": "^28.0.0", "electron-log": "^5.1.0", @@ -144,20 +144,20 @@ "react-intl": "^6.6.5", "react-resizable-panels": "^1.0.8", "scroll-into-view-if-needed": "^3.0.10", - "selenium-webdriver": "^4.20.0", + "selenium-webdriver": "^4.25.0", "side-code-export": "^4.0.11", "v8-compile-cache": "^2.3.0" }, "devDependencies": { "@medv/finder": "^1.1.1", - "@seleniumhq/browser-info": "4.0.12", + "@seleniumhq/browser-info": "4.0.13", "@types/copy-webpack-plugin": "8.0.1", "@types/electron-devtools-installer": "^2.2.5", "@types/fs-extra": "^11.0.1", "@types/lodash": "^4.14.199", "@types/react": "^18.2.15", "@types/react-dom": "^18.2.7", - "@types/selenium-webdriver": "^4.1.22", + "@types/selenium-webdriver": "^4.1.26", "@types/webpack-env": "^1.16.0", "copy-webpack-plugin": "^10.2.4", "css-loader": "^6.8.1", diff --git a/packages/side-api/package.json b/packages/side-api/package.json index 53953985e4..06c7aee912 100644 --- a/packages/side-api/package.json +++ b/packages/side-api/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-api", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Selenium IDE API command shapes and such.", "author": "Todd Tarsi ", @@ -20,10 +20,10 @@ "dist" ], "dependencies": { - "@seleniumhq/browser-info": "4.0.12", - "@seleniumhq/get-driver": "4.0.12", - "@seleniumhq/side-model": "4.0.12", - "@seleniumhq/side-runtime": "4.0.12", + "@seleniumhq/browser-info": "4.0.13", + "@seleniumhq/get-driver": "4.0.13", + "@seleniumhq/side-model": "4.0.13", + "@seleniumhq/side-runtime": "4.0.13", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/packages/side-code-export/package.json b/packages/side-code-export/package.json index 68d9054f25..c7063ec1e6 100644 --- a/packages/side-code-export/package.json +++ b/packages/side-code-export/package.json @@ -1,6 +1,6 @@ { "name": "side-code-export", - "version": "4.0.12", + "version": "4.0.13", "description": "Utils for code export from Selenium IDE", "repository": "https://github.com/SeleniumHQ/selenium-ide", "keywords": [ @@ -20,8 +20,8 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "dependencies": { - "@seleniumhq/side-model": "4.0.12", - "@seleniumhq/side-runtime": "4.0.12", + "@seleniumhq/side-model": "4.0.13", + "@seleniumhq/side-runtime": "4.0.13", "commander": "^9.4.0" }, "gitHead": "f58e327e7616e23a3e926e4b80cf9952164e5744" diff --git a/packages/side-commons/package.json b/packages/side-commons/package.json index defb74e35e..810a0c44b9 100644 --- a/packages/side-commons/package.json +++ b/packages/side-commons/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-commons", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Selenium IDE common utilities", "author": "Tomer ", diff --git a/packages/side-example-suite/package.json b/packages/side-example-suite/package.json index 231a2ec170..72cd1fa22e 100644 --- a/packages/side-example-suite/package.json +++ b/packages/side-example-suite/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-example-suite", - "version": "4.0.12", + "version": "4.0.13", "private": true, "description": "Selenium IDE example suite, with tests, plugin, and export format", "author": "Todd ", @@ -18,10 +18,10 @@ }, "dependencies": { "side-code-export": "^4.0.11", - "@seleniumhq/code-export-python-pytest": "4.0.12" + "@seleniumhq/code-export-python-pytest": "4.0.13" }, "devDependencies": { - "@seleniumhq/side-api": "4.0.12" + "@seleniumhq/side-api": "4.0.13" }, "repository": { "type": "git", diff --git a/packages/side-migrate/package.json b/packages/side-migrate/package.json index 7e1542f0fd..33d5dce500 100644 --- a/packages/side-migrate/package.json +++ b/packages/side-migrate/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-migrate", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Selenium IDE format migrations", "author": "Tomer ", diff --git a/packages/side-model/package.json b/packages/side-model/package.json index 5594a8629e..eb04a11ef2 100644 --- a/packages/side-model/package.json +++ b/packages/side-model/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-model", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Selenium IDE shared models", "author": "Tomer ", diff --git a/packages/side-runner/package.json b/packages/side-runner/package.json index d4cc70194f..cf3cc62133 100644 --- a/packages/side-runner/package.json +++ b/packages/side-runner/package.json @@ -1,6 +1,6 @@ { "name": "selenium-side-runner", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Run Selenium IDE projects in cli", "repository": "https://github.com/SeleniumHQ/selenium-ide", @@ -23,8 +23,8 @@ ], "license": "Apache-2.0", "dependencies": { - "@seleniumhq/side-model": "4.0.12", - "@seleniumhq/side-runtime": "4.0.12", + "@seleniumhq/side-model": "4.0.13", + "@seleniumhq/side-runtime": "4.0.13", "commander": "^11.0.0", "glob": "^10.3.1", "jest": "^29.6.0", diff --git a/packages/side-runtime/package.json b/packages/side-runtime/package.json index eecbeba041..d580563c6d 100644 --- a/packages/side-runtime/package.json +++ b/packages/side-runtime/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-runtime", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Selenium IDE playback and execution", "author": "Tomer ", @@ -25,15 +25,15 @@ "url": "https://github.com/SeleniumHQ/selenium-ide/issues" }, "devDependencies": { - "@seleniumhq/get-driver": "4.0.12", - "@seleniumhq/side-testkit": "4.0.12", - "@seleniumhq/webdriver-testkit": "4.0.12" + "@seleniumhq/get-driver": "4.0.13", + "@seleniumhq/side-testkit": "4.0.13", + "@seleniumhq/webdriver-testkit": "4.0.13" }, "dependencies": { - "@seleniumhq/side-commons": "4.0.12", - "@seleniumhq/side-model": "4.0.12", - "@types/selenium-webdriver": "^4.1.22", - "selenium-webdriver": "^4.20.0" + "@seleniumhq/side-commons": "4.0.13", + "@seleniumhq/side-model": "4.0.13", + "@types/selenium-webdriver": "^4.1.26", + "selenium-webdriver": "^4.25.0" }, "gitHead": "507c7c802f34196e6ee4800bf5c0b36553d41369" } diff --git a/packages/side-runtime/src/webdriver.ts b/packages/side-runtime/src/webdriver.ts index 48f766210a..5b04da5344 100644 --- a/packages/side-runtime/src/webdriver.ts +++ b/packages/side-runtime/src/webdriver.ts @@ -860,7 +860,9 @@ export default class WebDriverExecutor { commandObject.fallbackTargets ) await element.clear() - await element.sendKeys(value) + if (value) { + await element.sendKeys(value) + } } async doSendKeys( diff --git a/packages/side-test-metaparser/jest.config.js b/packages/side-test-metaparser/jest.config.js new file mode 100644 index 0000000000..da34b7ddb5 --- /dev/null +++ b/packages/side-test-metaparser/jest.config.js @@ -0,0 +1,10 @@ +module.exports = { + testEnvironmentOptions: { + url: 'http://localhost/index.html', + }, + testMatch: ['**/packages/**/__test?(s)__/**/*.spec.[jt]s?(x)'], + testPathIgnorePatterns: ['/node_modules/', '/dist/'], + transform: { + '^.+\\.ts?$': 'ts-jest', + }, +} diff --git a/packages/side-test-metaparser/package.json b/packages/side-test-metaparser/package.json new file mode 100644 index 0000000000..eb3a06909f --- /dev/null +++ b/packages/side-test-metaparser/package.json @@ -0,0 +1,28 @@ +{ + "name": "@seleniumhq/side-test-metaparser", + "version": "4.0.13", + "private": false, + "description": "Reads code to JSON and back", + "author": "Todd Tarsi ", + "homepage": "http://github.com/SeleniumHQ/selenium-ide", + "license": "Apache-2.0", + "scripts": { + "build": "tsc", + "clean": "rm -rf dist tsconfig.tsbuildinfo node_modules", + "try": "node dist/comment.ts", + "watch": "tsc --watch" + }, + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/SeleniumHQ/selenium-ide.git" + }, + "bugs": { + "url": "https://github.com/SeleniumHQ/selenium-ide/issues" + }, + "gitHead": "507c7c802f34196e6ee4800bf5c0b36553d41369" +} diff --git a/packages/side-test-metaparser/src/index.ts b/packages/side-test-metaparser/src/index.ts new file mode 100644 index 0000000000..c3b2dddd37 --- /dev/null +++ b/packages/side-test-metaparser/src/index.ts @@ -0,0 +1,47 @@ +import commentParser from './parsers/comment' +import logParser from './parsers/log-string-static' + +type Language = { + parsers: { + comment: (block: string) => string | null + log: (block: string) => string | null + findElement: (locatorType: string, locator: string) => string | null + click: (locatorType: string, locator: string) => string | null + select: ( + locatorType: string, + locator: string, + selectorType: string, + selector: string + ) => string | null + sendKeys: (locatorType: string, locator: string) => string | null + } +} + +export const buildLanguageFromFile = (file: string): Language => { + const lines = file.split('\n') + console.log('Parsing comments') + const commentLine = lines.find((line) => line.includes('COMMENT_STRING')) + if (!commentLine) { + throw new Error(` + Unable to find comment line in file. + Please ensure that the file contains a single line comment with the string 'COMMENT_STRING' + `) + } + const parseComment = commentParser(commentLine) + console.log('Parsing log statement') + const printLog = lines.find((line) => line.includes('LOG_STRING')) + if (!printLog) { + throw new Error(` + Unable to find print line in file. + Please ensure that the file contains a log command with the string 'LOG_STRING' + `) + } + const parseLog = logParser(printLog) + + return { + parsers: { + comment: parseComment, + log: parseLog.parse, + } as any, + } +} diff --git a/packages/side-test-metaparser/src/lang-example.ts b/packages/side-test-metaparser/src/lang-example.ts new file mode 100644 index 0000000000..b8244fbb26 --- /dev/null +++ b/packages/side-test-metaparser/src/lang-example.ts @@ -0,0 +1,110 @@ +// This is a big import block area but I'm just gonna write some stuff + +type Variables = Record +const globalVars: Variables = {} + +const suiteBlock = async (name: string, fn: () => any) => { + console.log('Begin suite', name) + await fn() + console.log('End suite', name) +} + +const testBlock = async (name: string, fn: () => any) => { + console.log('Begin test', name) + await fn() + console.log('End test', name) +} + +const findElement = (locatorType: 'css' | 'xpath', locator: string) => { + console.log( + 'Finding element using locator type', + locatorType, + 'and locator', + locator + ) + return { + clear: () => null, + click: () => null, + select: (_selectorType: 'label' | 'name' | 'value', _selector: any) => null, + sendKeys: (_keys: string) => null, + sendMultiKeys: (_keys: string[]) => null, + storeAttribute: (_attribute: string) => null, + storeText: (_text: string) => null, + storeValue: (_value: any) => null, + waitForAttribute: (_attribute: string, _value: any, _time: number) => null, + waitForText: (_text: string, _time: number) => null, + waitForValue: (_value: any, _time: number) => null, + } +} + +const performCustomAction = ( + _actionName: string, + _actionVariable1: string, + _actionVariable2: number +) => null + +const executeScript = (_script: string) => _script + +suiteBlock('BEGIN_SUITE', async () => { + const suiteVars: Variables = {} + testBlock('BEGIN_TEST', async () => { + const testVars: Variables = {} + const NUM_TIMEOUT = 0 + // COMMENT_STRING + console.log('LOG_STRING_STATIC') + console.log(`${'LOG_STRING_WITH_VARIABLES'}`) + globalVars.foo = 'SET_GLOBAL_VARIABLE' + suiteVars.foo = 'SET_SUITE_VARIABLE' + testVars.foo = 'SET_TEST_VARIABLE' + suiteVars.nestedVars = [{ a: '' }] + suiteVars.nestedVars[0]['a'] = 'SET_NESTED_VARIABLE' + + findElement('css', '.LOCATOR_CSS') + findElement('xpath', '//*[@id="LOCATOR_XPATH"]') + findElement('css', '.CLICK').click() + findElement('css', '.SEND_KEYS').sendKeys('SEND_KEYS_STRING') + + // BEGIN_SEND_MULTI_KEYS + findElement('css', '.SEND_MULTI_KEYS').sendMultiKeys([ + 'SEND_MULTI_KEYS_1', + 'SEND_MULTI_KEYS_2', + ]) + // END_SEND_MULTI_KEYS + + findElement('css', '.SELECT_LABEL').select('label', 'SELECTOR') + findElement('css', '.SELECT_NAME').select('name', 'SELECTOR') + findElement('css', '.SELECT_VALUE').select('value', 'SELECTOR') + + findElement('css', '.STORE_ATTRIBUTE').storeAttribute('ATTRIBUTE') + findElement('css', '.STORE_TEXT').storeText('TEXT') + findElement('css', '.STORE_VALUE').storeValue('VALUE') + + // BEGIN_WAIT_FOR_ATTRIBUTE + findElement('css', '.WAIT_FOR_ATTRIBUTE').waitForAttribute( + 'ATTRIBUTE', + 'VALUE', + NUM_TIMEOUT + ) + // END_WAIT_FOR_ATTRIBUTE + + findElement('css', '.WAIT_FOR_TEXT').waitForText('TEXT', NUM_TIMEOUT) + findElement('css', '.WAIT_FOR_VALUE').waitForValue('VALUE', NUM_TIMEOUT) + + // BEGIN EXECUTE_SCRIPT + globalVars.EXECUTE_SCRIPT_VARIABLE_NAME = executeScript( + 'return "EXECUTE_SCRIPT_BODY";' + ) + // END EXECUTE_SCRIPT + + const NUM_ACTION_VARIABLE_2 = 5 + // BEGIN_PERFORM_CUSTOM_ACTION + performCustomAction( + 'PERFORM_CUSTOM_ACTION_ACTION_NAME', + 'ACTION_VARIABLE_1', + NUM_ACTION_VARIABLE_2 + ) + // END_PERFORM_CUSTOM_ACTION + // END TEST + }) + // END SUITE +}) diff --git a/packages/side-test-metaparser/src/parsers/click.ts b/packages/side-test-metaparser/src/parsers/click.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/comment.ts b/packages/side-test-metaparser/src/parsers/comment.ts new file mode 100644 index 0000000000..80de23f70f --- /dev/null +++ b/packages/side-test-metaparser/src/parsers/comment.ts @@ -0,0 +1,23 @@ +export default (commentLine: string) => { + const match = commentLine.match( + // Regex pattern to capture prefix and postfix + /(?^[^a-zA-Z0-9]*)(?COMMENT_STRING)(?[^a-zA-Z0-9]*$)/ + ) + if (!match?.groups?.prefix) { + throw new Error('Unable to parse comment training line: ' + commentLine) + } + return (line: string) => { + const cleanedLine = line.trim() + if (!cleanedLine.startsWith(match!.groups!.prefix)) { + return null + } + const postfix = match?.groups?.postfix + if (postfix && !cleanedLine.endsWith(postfix)) { + return null + } + return cleanedLine.slice( + match!.groups!.prefix.length, + postfix ? -postfix.length : cleanedLine.length + ) + } +} diff --git a/packages/side-test-metaparser/src/parsers/execute-script.ts b/packages/side-test-metaparser/src/parsers/execute-script.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/find-element-locator.ts b/packages/side-test-metaparser/src/parsers/find-element-locator.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/log-string-static.ts b/packages/side-test-metaparser/src/parsers/log-string-static.ts new file mode 100644 index 0000000000..cebe0f4b51 --- /dev/null +++ b/packages/side-test-metaparser/src/parsers/log-string-static.ts @@ -0,0 +1,28 @@ +// Regex pattern to capture prefix, quote type, and postfix of log commands +const createLogParser = (logLine: string) => { + const pattern = + /^(?.*?)\(\s*(?['"`])\$\{(?[a-zA-Z_][a-zA-Z0-9_]*)\}(?['"`])\s*\)$/ + + const match = logLine.match(pattern) + if (!match?.groups?.prefix) { + throw new Error('Unable to parse comment training line: ' + logLine) + } + return { + parse: (line: string) => { + const cleanedLine = line.trim() + if (!cleanedLine.startsWith(match!.groups!.prefix)) { + return null + } + const postfix = match?.groups?.postfix + if (postfix && !cleanedLine.endsWith(postfix)) { + return null + } + return cleanedLine.slice( + match!.groups!.prefix.length, + postfix ? -postfix.length : cleanedLine.length + ) + }, + } +} + +export default createLogParser diff --git a/packages/side-test-metaparser/src/parsers/log-string-with-variables.ts b/packages/side-test-metaparser/src/parsers/log-string-with-variables.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/select-element.ts b/packages/side-test-metaparser/src/parsers/select-element.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/send-keys.ts b/packages/side-test-metaparser/src/parsers/send-keys.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/set-nested-variable.ts b/packages/side-test-metaparser/src/parsers/set-nested-variable.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/set-variable.ts b/packages/side-test-metaparser/src/parsers/set-variable.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/wait-for-attribute.ts b/packages/side-test-metaparser/src/parsers/wait-for-attribute.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/wait-for-text.ts b/packages/side-test-metaparser/src/parsers/wait-for-text.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/parsers/wait-for-value.ts b/packages/side-test-metaparser/src/parsers/wait-for-value.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/side-test-metaparser/src/types.ts b/packages/side-test-metaparser/src/types.ts new file mode 100644 index 0000000000..5698dc2814 --- /dev/null +++ b/packages/side-test-metaparser/src/types.ts @@ -0,0 +1,4 @@ +export type Parser> = { + parse: (line: string) => string | null + write: (options: OPTS) => string +} diff --git a/packages/side-test-metaparser/tsconfig.json b/packages/side-test-metaparser/tsconfig.json new file mode 100644 index 0000000000..d47e325667 --- /dev/null +++ b/packages/side-test-metaparser/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./src", + "rootDir": "src", + "outDir": "dist" + }, + "include": ["src/**/*.ts"], + "exclude": ["**/__mocks__"], + "references": [ + { + "path": "../side-commons" + }, + { + "path": "../side-model" + }, + { + "path": "../side-testkit" + }, + { + "path": "../webdriver-testkit" + } + ], + "types": ["node", "jest"] +} diff --git a/packages/side-testkit/package.json b/packages/side-testkit/package.json index 59f3b1ceed..f01023a8ae 100644 --- a/packages/side-testkit/package.json +++ b/packages/side-testkit/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/side-testkit", - "version": "4.0.12", + "version": "4.0.13", "private": false, "description": "Selenium IDE test stuff", "author": "Tomer ", diff --git a/packages/webdriver-testkit/package.json b/packages/webdriver-testkit/package.json index 66e2b611b5..ac6e76abff 100644 --- a/packages/webdriver-testkit/package.json +++ b/packages/webdriver-testkit/package.json @@ -1,6 +1,6 @@ { "name": "@seleniumhq/webdriver-testkit", - "version": "4.0.12", + "version": "4.0.13", "private": true, "description": "Manage test driver installation", "author": "Tomer ", @@ -26,12 +26,12 @@ }, "devDependencies": { "@types/fs-extra": "^8.0.1", - "@types/selenium-webdriver": "^4.1.22", - "selenium-webdriver": "^4.20.0" + "@types/selenium-webdriver": "^4.1.26", + "selenium-webdriver": "^4.25.0" }, "dependencies": { - "@seleniumhq/browser-info": "4.0.12", - "@seleniumhq/get-driver": "4.0.12", + "@seleniumhq/browser-info": "4.0.13", + "@seleniumhq/get-driver": "4.0.13", "fs-extra": "^8.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b8dc24b293..83aa71cd1e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -135,13 +135,13 @@ importers: version: link:../side-code-export devDependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model packages/code-export-csharp-nunit: dependencies: '@seleniumhq/code-export-csharp-commons': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-csharp-commons side-code-export: specifier: ^4.0.11 @@ -150,14 +150,14 @@ importers: packages/code-export-csharp-xunit: dependencies: '@seleniumhq/code-export-csharp-commons': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-csharp-commons side-code-export: specifier: ^4.0.11 version: link:../side-code-export devDependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model packages/code-export-java-junit: @@ -167,7 +167,7 @@ importers: version: link:../side-code-export devDependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model packages/code-export-javascript-mocha: @@ -177,7 +177,7 @@ importers: version: link:../side-code-export devDependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model packages/code-export-python-pytest: @@ -187,7 +187,7 @@ importers: version: link:../side-code-export devDependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model packages/code-export-ruby-rspec: @@ -197,7 +197,7 @@ importers: version: link:../side-code-export devDependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model packages/get-driver: @@ -246,37 +246,37 @@ importers: specifier: ^5.15.13 version: 5.15.13(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0) '@seleniumhq/code-export-csharp-nunit': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-csharp-nunit '@seleniumhq/code-export-csharp-xunit': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-csharp-xunit '@seleniumhq/code-export-java-junit': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-java-junit '@seleniumhq/code-export-javascript-mocha': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-javascript-mocha '@seleniumhq/code-export-python-pytest': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-python-pytest '@seleniumhq/code-export-ruby-rspec': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-ruby-rspec '@seleniumhq/get-driver': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../get-driver '@seleniumhq/side-api': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-api '@seleniumhq/side-commons': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-commons '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model '@seleniumhq/side-runtime': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-runtime dnd-core: specifier: ^16.0.1 @@ -324,8 +324,8 @@ importers: specifier: ^3.0.10 version: 3.0.10 selenium-webdriver: - specifier: ^4.20.0 - version: 4.20.0 + specifier: ^4.25.0 + version: 4.26.0 side-code-export: specifier: ^4.0.11 version: link:../side-code-export @@ -337,7 +337,7 @@ importers: specifier: ^1.1.1 version: 1.1.3 '@seleniumhq/browser-info': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../browser-info '@types/copy-webpack-plugin': specifier: 8.0.1 @@ -358,8 +358,8 @@ importers: specifier: ^18.2.7 version: 18.2.7 '@types/selenium-webdriver': - specifier: ^4.1.22 - version: 4.1.22 + specifier: ^4.1.26 + version: 4.1.27 '@types/webpack-env': specifier: ^1.16.0 version: 1.18.0 @@ -424,16 +424,16 @@ importers: packages/side-api: dependencies: '@seleniumhq/browser-info': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../browser-info '@seleniumhq/get-driver': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../get-driver '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model '@seleniumhq/side-runtime': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-runtime lodash: specifier: ^4.17.21 @@ -474,10 +474,10 @@ importers: packages/side-code-export: dependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model '@seleniumhq/side-runtime': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-runtime commander: specifier: ^9.4.0 @@ -488,14 +488,14 @@ importers: packages/side-example-suite: dependencies: '@seleniumhq/code-export-python-pytest': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../code-export-python-pytest side-code-export: specifier: ^4.0.11 version: link:../side-code-export devDependencies: '@seleniumhq/side-api': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-api packages/side-migrate: @@ -525,10 +525,10 @@ importers: packages/side-runner: dependencies: '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model '@seleniumhq/side-runtime': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-runtime commander: specifier: ^11.0.0 @@ -580,28 +580,30 @@ importers: packages/side-runtime: dependencies: '@seleniumhq/side-commons': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-commons '@seleniumhq/side-model': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-model '@types/selenium-webdriver': - specifier: ^4.1.22 - version: 4.1.22 + specifier: ^4.1.26 + version: 4.1.27 selenium-webdriver: - specifier: ^4.20.0 - version: 4.20.0 + specifier: ^4.25.0 + version: 4.26.0 devDependencies: '@seleniumhq/get-driver': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../get-driver '@seleniumhq/side-testkit': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../side-testkit '@seleniumhq/webdriver-testkit': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../webdriver-testkit + packages/side-test-metaparser: {} + packages/side-testkit: dependencies: express: @@ -615,10 +617,10 @@ importers: packages/webdriver-testkit: dependencies: '@seleniumhq/browser-info': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../browser-info '@seleniumhq/get-driver': - specifier: 4.0.12 + specifier: 4.0.13 version: link:../get-driver fs-extra: specifier: ^8.1.0 @@ -628,11 +630,11 @@ importers: specifier: ^8.0.1 version: 8.1.2 '@types/selenium-webdriver': - specifier: ^4.1.22 - version: 4.1.22 + specifier: ^4.1.26 + version: 4.1.27 selenium-webdriver: - specifier: ^4.20.0 - version: 4.20.0 + specifier: ^4.25.0 + version: 4.26.0 packages: @@ -2143,6 +2145,9 @@ packages: hasBin: true dev: true + /@bazel/runfiles@6.3.1: + resolution: {integrity: sha512-1uLNT5NZsUVIGS4syuHwTzZ8HycMPyr6POA3FCE4GbMtc4rhoJk8aZKtNIRthJYfL+iioppi+rTfH3olMPr9nA==} + /@bazel/typescript@5.8.1(typescript@5.1.6): resolution: {integrity: sha512-NAJ8WQHZL1WE1YmRoCrq/1hhG15Mvy/viWh6TkvFnBeEhNUiQUsA5GYyhU1ztnBIYW03nATO3vwhAEfO7Q0U5g==} deprecated: No longer maintained, https://github.com/aspect-build/rules_ts is the recommended replacement @@ -3721,9 +3726,10 @@ packages: /@types/scheduler@0.16.2: resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} - /@types/selenium-webdriver@4.1.22: - resolution: {integrity: sha512-MCL4l7q8dwxejr2Q2NXLyNwHWMPdlWE0Kpn6fFwJtvkJF7PTkG5jkvbH/X1IAAQxgt/L1dA8u2GtDeekvSKvOA==} + /@types/selenium-webdriver@4.1.27: + resolution: {integrity: sha512-ALqsj8D7Swb6MnBQuAQ58J3KC3yh6fLGtAmpBmnZX8j+0kmP7NaLt56CuzBw2W2bXPrvHFTgn8iekOQFUKXEQA==} dependencies: + '@types/node': 16.11.64 '@types/ws': 8.5.10 /@types/semver@7.5.0: @@ -10453,13 +10459,14 @@ packages: resolution: {integrity: sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg==} dev: true - /selenium-webdriver@4.20.0: - resolution: {integrity: sha512-s/G44lGQ1xB3tmtX6NNPomlkpL6CxLdmAvp/AGWWwi4qv5Te1+qji7tPSyr6gyuoPpdYiof1rKnWe3luy0MrYA==} - engines: {node: '>= 14.20.0'} + /selenium-webdriver@4.26.0: + resolution: {integrity: sha512-nA7jMRIPV17mJmAiTDBWN96Sy0Uxrz5CCLb7bLVV6PpL417SyBMPc2Zo/uoREc2EOHlzHwHwAlFtgmSngSY4WQ==} + engines: {node: '>= 14.21.0'} dependencies: + '@bazel/runfiles': 6.3.1 jszip: 3.10.1 tmp: 0.2.3 - ws: 8.16.0 + ws: 8.18.0 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -12077,6 +12084,19 @@ packages: optional: true utf-8-validate: optional: true + dev: true + + /ws@8.18.0: + resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true /xml-escape@1.1.0: resolution: {integrity: sha512-B/T4sDK8Z6aUh/qNr7mjKAwwncIljFuUP+DO/D5hloYFj+90O88z8Wf7oSucZTHxBAsC1/CTP4rtx/x1Uf72Mg==} diff --git a/tsconfig.json b/tsconfig.json index c4a5ac05b9..a59723ad93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -61,6 +61,9 @@ { "path": "./packages/side-testkit" }, + { + "path": "./packages/side-test-metaparser" + }, { "path": "./packages/webdriver-testkit" }