diff --git a/CHANGELOG.md b/CHANGELOG.md index c38ea11..ed0505e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,17 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how :microscope: - experimental +## [2.9.0] +- :rocket: added capability to execute script on electron main process +```gherkin +Scenario: evaluate script on main process + When I execute '$js(async ({ app }) => app.showAboutPanel())' script on electron app + +Scenario: evaluate script on main process and save result to memory + When I execute '$js(async ({ app }) => app.getAppPath())' script on electron app and save result as 'appPath' + Then I expect '$appPath' memory value to contain 'test-e2e/apps/electron' +``` + ## [2.8.0] - :rocket: improved logging to display full path diff --git a/README.md b/README.md index e49247d..6ce857e 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ It enables easy and efficient browser automation in a behavior-driven developmen ## Features -- โœ… Predefined steps for web automation using Playwright -- ๐Ÿ”„ Seamless integration with `@qavajs/core` -- ๐Ÿงฉ Support for dynamic locators and parameters -- ๐Ÿงช Built-in assertions and synchronization steps -- ๐Ÿ”ง Easily extendable for custom needs +- Predefined steps for web automation using Playwright +- Seamless integration with `@qavajs/core` +- Support for dynamic locators and parameters +- Built-in assertions and synchronization steps +- Easily extendable for custom needs ## Installation ```bash diff --git a/index.js b/index.js index 761e6c9..e7f4c9b 100644 --- a/index.js +++ b/index.js @@ -13,3 +13,4 @@ require('./lib/poDefine.js'); require('./lib/mouseActions.js'); require('./lib/keyboardActions.js'); require('./lib/dialog.js'); +require('./lib/electron.js'); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c1f81b0..dce655d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@qavajs/steps-playwright", - "version": "2.8.0", + "version": "2.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@qavajs/steps-playwright", - "version": "2.8.0", + "version": "2.9.0", "license": "MIT", "dependencies": { "@playwright/test": "^1.55.0" @@ -20,7 +20,7 @@ "@qavajs/validation": "^1.3.0", "@qavajs/webstorm-adapter": "^8.0.0", "@types/express": "^5.0.3", - "@types/node": "^24.3.0", + "@types/node": "^24.3.1", "@vitest/coverage-v8": "^3.2.4", "@vitest/ui": "^3.2.4", "electron": "^38.0.0", @@ -1855,9 +1855,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.3.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.0.tgz", - "integrity": "sha512-aPTXCrfwnDLj4VvXrm+UUCQjNEvJgNA8s5F1cvwQU+3KNltTOkBm1j30uNLyqqPNe7gE3KFzImYoZEfLhp4Yow==", + "version": "24.3.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.1.tgz", + "integrity": "sha512-3vXmQDXy+woz+gnrTvuvNrPzekOi+Ds0ReMxw0LzBiK3a+1k0kQn9f2NWk+lgD4rJehFUmYy2gMhJ2ZI+7YP9g==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index f356d28..e6a4afe 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@qavajs/steps-playwright", - "version": "2.8.0", - "description": "steps to interact with playwright", + "version": "2.9.0", + "description": "qavajs steps to interact with playwright", "main": "./index.js", "scripts": { "build": "tsc", @@ -34,7 +34,7 @@ "@qavajs/validation": "^1.3.0", "@qavajs/webstorm-adapter": "^8.0.0", "@types/express": "^5.0.3", - "@types/node": "^24.3.0", + "@types/node": "^24.3.1", "@vitest/coverage-v8": "^3.2.4", "@vitest/ui": "^3.2.4", "electron": "^38.0.0", @@ -45,5 +45,31 @@ }, "dependencies": { "@playwright/test": "^1.55.0" - } + }, + "keywords": [ + "test", + "automation", + "testing", + "qa", + "quality-assurance", + "test-framework", + "test-runner", + "test-automation", + "e2e", + "end-to-end", + "ui-testing", + "integration-testing", + "acceptance-testing", + "functional-testing", + "browser-testing", + "mobile-testing", + "cross-browser", + "bdd", + "gherkin", + "assertions", + "continuous-delivery", + "automation-framework", + "playwright", + "webdriver" + ] } diff --git a/src/electron.ts b/src/electron.ts new file mode 100644 index 0000000..77be9f6 --- /dev/null +++ b/src/electron.ts @@ -0,0 +1,23 @@ +import { type MemoryValue, When } from '@qavajs/core'; + +/** + * Execute client function on electron process and save result into memory + * @param {string} functionKey - memory key of function + * @param {string} memoryKey - memory key to store result + * @example I execute '$fn' function and save result as 'result' // fn is function reference + * @example I execute '$js(async ({ app }) => app.getAppPath())' function and save result as 'scroll' + */ +When('I execute {value} function/script on electron app', async function (fn: MemoryValue) { + await this.playwright.driver.evaluate(await fn.value()); +}); + +/** + * Execute client function on electron process and save result into memory + * @param {string} functionKey - memory key of function + * @param {string} memoryKey - memory key to store result + * @example I execute '$fn' function and save result as 'result' // fn is function reference + * @example I execute '$js(async ({ app }) => app.getAppPath())' function on electron app and save result as 'result' + */ +When('I execute {value} function/script on electron app and save result as {value}', async function (fn: MemoryValue, memoryKey: MemoryValue) { + memoryKey.set(await this.playwright.driver.evaluate(await fn.value())); +}); \ No newline at end of file diff --git a/test-e2e/features/electron/electron.feature b/test-e2e/features/electron/electron.feature index 82a458f..f33b974 100644 --- a/test-e2e/features/electron/electron.feature +++ b/test-e2e/features/electron/electron.feature @@ -3,4 +3,11 @@ Feature: electron Scenario: open electron app * I click 'Open New Window Electron Button' * I switch to 'qavajs electron app new window' window - * I click 'Close Current Window Electron Button' \ No newline at end of file + * I click 'Close Current Window Electron Button' + + Scenario: evaluate script on main process + * I execute '$js(async ({ app }) => app.showAboutPanel())' script on electron app + + Scenario: evaluate script on main process and save result to memory + * I execute '$js(async ({ app }) => app.getAppPath())' script on electron app and save result as 'appPath' + * I expect '$appPath' memory value to contain 'test-e2e/apps/electron' \ No newline at end of file