Skip to content

Commit af10ca9

Browse files
author
Oleksandr_Halichenko
committed
added capability to execute script on electron main process
1 parent 2663554 commit af10ca9

File tree

7 files changed

+84
-16
lines changed

7 files changed

+84
-16
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1414

1515
:microscope: - experimental
1616

17+
## [2.9.0]
18+
- :rocket: added capability to execute script on electron main process
19+
```gherkin
20+
Scenario: evaluate script on main process
21+
When I execute '$js(async ({ app }) => app.showAboutPanel())' script on electron app
22+
23+
Scenario: evaluate script on main process and save result to memory
24+
When I execute '$js(async ({ app }) => app.getAppPath())' script on electron app and save result as 'appPath'
25+
Then I expect '$appPath' memory value to contain 'test-e2e/apps/electron'
26+
```
27+
1728
## [2.8.0]
1829
- :rocket: improved logging to display full path
1930

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ It enables easy and efficient browser automation in a behavior-driven developmen
66

77
## Features
88

9-
- Predefined steps for web automation using Playwright
10-
- 🔄 Seamless integration with `@qavajs/core`
11-
- 🧩 Support for dynamic locators and parameters
12-
- 🧪 Built-in assertions and synchronization steps
13-
- 🔧 Easily extendable for custom needs
9+
- Predefined steps for web automation using Playwright
10+
- Seamless integration with `@qavajs/core`
11+
- Support for dynamic locators and parameters
12+
- Built-in assertions and synchronization steps
13+
- Easily extendable for custom needs
1414

1515
## Installation
1616
```bash

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ require('./lib/poDefine.js');
1313
require('./lib/mouseActions.js');
1414
require('./lib/keyboardActions.js');
1515
require('./lib/dialog.js');
16+
require('./lib/electron.js');

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@qavajs/steps-playwright",
3-
"version": "2.8.0",
4-
"description": "steps to interact with playwright",
3+
"version": "2.9.0",
4+
"description": "qavajs steps to interact with playwright",
55
"main": "./index.js",
66
"scripts": {
77
"build": "tsc",
@@ -34,7 +34,7 @@
3434
"@qavajs/validation": "^1.3.0",
3535
"@qavajs/webstorm-adapter": "^8.0.0",
3636
"@types/express": "^5.0.3",
37-
"@types/node": "^24.3.0",
37+
"@types/node": "^24.3.1",
3838
"@vitest/coverage-v8": "^3.2.4",
3939
"@vitest/ui": "^3.2.4",
4040
"electron": "^38.0.0",
@@ -45,5 +45,31 @@
4545
},
4646
"dependencies": {
4747
"@playwright/test": "^1.55.0"
48-
}
48+
},
49+
"keywords": [
50+
"test",
51+
"automation",
52+
"testing",
53+
"qa",
54+
"quality-assurance",
55+
"test-framework",
56+
"test-runner",
57+
"test-automation",
58+
"e2e",
59+
"end-to-end",
60+
"ui-testing",
61+
"integration-testing",
62+
"acceptance-testing",
63+
"functional-testing",
64+
"browser-testing",
65+
"mobile-testing",
66+
"cross-browser",
67+
"bdd",
68+
"gherkin",
69+
"assertions",
70+
"continuous-delivery",
71+
"automation-framework",
72+
"playwright",
73+
"webdriver"
74+
]
4975
}

src/electron.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { type MemoryValue, When } from '@qavajs/core';
2+
3+
/**
4+
* Execute client function on electron process and save result into memory
5+
* @param {string} functionKey - memory key of function
6+
* @param {string} memoryKey - memory key to store result
7+
* @example I execute '$fn' function and save result as 'result' // fn is function reference
8+
* @example I execute '$js(async ({ app }) => app.getAppPath())' function and save result as 'scroll'
9+
*/
10+
When('I execute {value} function/script on electron app', async function (fn: MemoryValue) {
11+
await this.playwright.driver.evaluate(await fn.value());
12+
});
13+
14+
/**
15+
* Execute client function on electron process and save result into memory
16+
* @param {string} functionKey - memory key of function
17+
* @param {string} memoryKey - memory key to store result
18+
* @example I execute '$fn' function and save result as 'result' // fn is function reference
19+
* @example I execute '$js(async ({ app }) => app.getAppPath())' function on electron app and save result as 'result'
20+
*/
21+
When('I execute {value} function/script on electron app and save result as {value}', async function (fn: MemoryValue, memoryKey: MemoryValue) {
22+
memoryKey.set(await this.playwright.driver.evaluate(await fn.value()));
23+
});

test-e2e/features/electron/electron.feature

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@ Feature: electron
33
Scenario: open electron app
44
* I click 'Open New Window Electron Button'
55
* I switch to 'qavajs electron app new window' window
6-
* I click 'Close Current Window Electron Button'
6+
* I click 'Close Current Window Electron Button'
7+
8+
Scenario: evaluate script on main process
9+
* I execute '$js(async ({ app }) => app.showAboutPanel())' script on electron app
10+
11+
Scenario: evaluate script on main process and save result to memory
12+
* I execute '$js(async ({ app }) => app.getAppPath())' script on electron app and save result as 'appPath'
13+
* I expect '$appPath' memory value to contain 'test-e2e/apps/electron'

0 commit comments

Comments
 (0)