promod 2.5.4 → 3.0.1
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/built/cjs/config.d.ts +43 -0
- package/built/cjs/config.js +161 -0
- package/built/cjs/config.js.map +1 -0
- package/built/cjs/helpers/execute.script.d.ts +1 -1
- package/built/cjs/helpers/execute.script.js +1 -3
- package/built/cjs/helpers/execute.script.js.map +1 -1
- package/built/cjs/index.d.ts +3 -1
- package/built/cjs/index.js +4 -1
- package/built/cjs/index.js.map +1 -1
- package/built/cjs/interface.d.ts +8 -4
- package/built/cjs/mappers.d.ts +1 -1
- package/built/cjs/mappers.js.map +1 -1
- package/built/cjs/pw/index.d.ts +2 -2
- package/built/cjs/pw/pw_client.d.ts +12 -11
- package/built/cjs/pw/pw_client.js +47 -58
- package/built/cjs/pw/pw_client.js.map +1 -1
- package/built/cjs/pw/pw_element.d.ts +17 -16
- package/built/cjs/pw/pw_element.js +19 -46
- package/built/cjs/pw/pw_element.js.map +1 -1
- package/built/cjs/shared/custom_selector_filter.d.ts +19 -0
- package/built/cjs/shared/custom_selector_filter.js +40 -0
- package/built/cjs/shared/custom_selector_filter.js.map +1 -0
- package/built/cjs/shared/validate_browser.d.ts +7 -0
- package/built/cjs/shared/validate_browser.js +29 -0
- package/built/cjs/shared/validate_browser.js.map +1 -0
- package/built/cjs/swd/swd_alignment.d.ts +1 -1
- package/built/cjs/swd/swd_alignment.js +2 -28
- package/built/cjs/swd/swd_alignment.js.map +1 -1
- package/built/cjs/swd/swd_client.d.ts +13 -10
- package/built/cjs/swd/swd_client.js +95 -31
- package/built/cjs/swd/swd_client.js.map +1 -1
- package/built/cjs/swd/swd_element.d.ts +14 -13
- package/built/cjs/swd/swd_element.js +13 -12
- package/built/cjs/swd/swd_element.js.map +1 -1
- package/built/esm/config.d.ts +43 -0
- package/built/esm/config.js +158 -0
- package/built/esm/config.js.map +1 -0
- package/built/esm/helpers/execute.script.d.ts +1 -1
- package/built/esm/helpers/execute.script.js +5 -9
- package/built/esm/helpers/execute.script.js.map +1 -1
- package/built/esm/index.d.ts +3 -1
- package/built/esm/index.js +4 -7
- package/built/esm/index.js.map +1 -1
- package/built/esm/interface.d.ts +8 -4
- package/built/esm/interface.js +1 -2
- package/built/esm/internals/index.js +1 -5
- package/built/esm/internals/index.js.map +1 -1
- package/built/esm/internals/logger.js +3 -6
- package/built/esm/internals/logger.js.map +1 -1
- package/built/esm/mappers.d.ts +1 -1
- package/built/esm/mappers.js +1 -7
- package/built/esm/mappers.js.map +1 -1
- package/built/esm/pw/index.d.ts +2 -2
- package/built/esm/pw/index.js +7 -10
- package/built/esm/pw/index.js.map +1 -1
- package/built/esm/pw/pw_client.d.ts +12 -11
- package/built/esm/pw/pw_client.js +103 -118
- package/built/esm/pw/pw_client.js.map +1 -1
- package/built/esm/pw/pw_element.d.ts +17 -16
- package/built/esm/pw/pw_element.js +84 -118
- package/built/esm/pw/pw_element.js.map +1 -1
- package/built/esm/shared/custom_selector_filter.d.ts +19 -0
- package/built/esm/shared/custom_selector_filter.js +38 -0
- package/built/esm/shared/custom_selector_filter.js.map +1 -0
- package/built/esm/shared/validate_browser.d.ts +7 -0
- package/built/esm/shared/validate_browser.js +27 -0
- package/built/esm/shared/validate_browser.js.map +1 -0
- package/built/esm/swd/index.js +7 -10
- package/built/esm/swd/index.js.map +1 -1
- package/built/esm/swd/swd_alignment.d.ts +1 -1
- package/built/esm/swd/swd_alignment.js +13 -42
- package/built/esm/swd/swd_alignment.js.map +1 -1
- package/built/esm/swd/swd_client.d.ts +13 -10
- package/built/esm/swd/swd_client.js +171 -111
- package/built/esm/swd/swd_client.js.map +1 -1
- package/built/esm/swd/swd_element.d.ts +14 -13
- package/built/esm/swd/swd_element.js +90 -97
- package/built/esm/swd/swd_element.js.map +1 -1
- package/docs/client.md +335 -111
- package/docs/config.md +176 -0
- package/docs/element.md +214 -141
- package/docs/elements.md +125 -65
- package/docs/init.md +66 -12
- package/oxlintrc.json +20 -0
- package/package.json +15 -18
- package/readme.md +114 -14
- package/tsconfig.esm.json +6 -2
- package/tsconfig.json +4 -1
package/docs/config.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Browser config
|
|
2
|
+
|
|
3
|
+
Define browser settings once and translate them to engine-specific configuration for Playwright or Selenium WebDriver. No auto-launching — you still call `chromium.launch()` / `new Builder().build()` yourself.
|
|
4
|
+
|
|
5
|
+
- [PromodBrowserConfig](#promodbrowserconfig)
|
|
6
|
+
- [toPwConfig](#topwconfig)
|
|
7
|
+
- [toSwdConfig](#toswdconfig)
|
|
8
|
+
- [Full example](#full-example)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## PromodBrowserConfig
|
|
13
|
+
|
|
14
|
+
A unified configuration object accepted by both translation functions.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const { toPwConfig, toSwdConfig } = require('promod');
|
|
18
|
+
|
|
19
|
+
const config = {
|
|
20
|
+
browserName: 'chrome',
|
|
21
|
+
headless: true,
|
|
22
|
+
args: ['--disable-gpu'],
|
|
23
|
+
viewport: { width: 1280, height: 720 },
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Property | Type | Description |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| `browserName` | `'chrome' \| 'firefox' \| 'webkit' \| 'edge'` | Target browser (required) |
|
|
30
|
+
| `headless` | `boolean` | Run without a visible window |
|
|
31
|
+
| `args` | `string[]` | Extra browser arguments |
|
|
32
|
+
| `executablePath` | `string` | Path to browser binary |
|
|
33
|
+
| `proxy` | `{ server, bypass?, username?, password? }` | Proxy settings |
|
|
34
|
+
| `viewport` | `{ width, height }` | Browser viewport size |
|
|
35
|
+
| `userAgent` | `string` | Custom user-agent string |
|
|
36
|
+
| `isMobile` | `boolean` | Emulate a mobile device |
|
|
37
|
+
| `deviceScaleFactor` | `number` | Device pixel ratio |
|
|
38
|
+
| `locale` | `string` | Browser locale (e.g. `'en-US'`) |
|
|
39
|
+
| `timezoneId` | `string` | Timezone (e.g. `'America/New_York'`) |
|
|
40
|
+
| `permissions` | `string[]` | Granted permissions (e.g. `['geolocation']`) |
|
|
41
|
+
| `geolocation` | `{ latitude, longitude, accuracy? }` | Geolocation override |
|
|
42
|
+
| `colorScheme` | `'light' \| 'dark' \| 'no-preference'` | Preferred color scheme |
|
|
43
|
+
| `ignoreHTTPSErrors` | `boolean` | Accept insecure certificates |
|
|
44
|
+
|
|
45
|
+
Only set properties appear in the output — no undefined keys are added.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## toPwConfig
|
|
50
|
+
|
|
51
|
+
Translates a `PromodBrowserConfig` into Playwright launch and context options.
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const { toPwConfig } = require('promod');
|
|
55
|
+
|
|
56
|
+
const { browserType, launchOptions, contextOptions } = toPwConfig({
|
|
57
|
+
browserName: 'chrome',
|
|
58
|
+
headless: true,
|
|
59
|
+
viewport: { width: 1280, height: 720 },
|
|
60
|
+
locale: 'en-US',
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
|
|
66
|
+
| Field | Type | Description |
|
|
67
|
+
| --- | --- | --- |
|
|
68
|
+
| `browserType` | `'chromium' \| 'firefox' \| 'webkit'` | Playwright browser type to launch |
|
|
69
|
+
| `launchOptions` | `object` | Passed to `chromium.launch(launchOptions)` |
|
|
70
|
+
| `contextOptions` | `object` | Passed to `browser.newContext()` or `setClient({ baseConfig })` |
|
|
71
|
+
|
|
72
|
+
Browser name mapping:
|
|
73
|
+
|
|
74
|
+
| `browserName` | `browserType` | Extra |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `'chrome'` | `'chromium'` | — |
|
|
77
|
+
| `'edge'` | `'chromium'` | `launchOptions.channel = 'msedge'` |
|
|
78
|
+
| `'firefox'` | `'firefox'` | — |
|
|
79
|
+
| `'webkit'` | `'webkit'` | — |
|
|
80
|
+
|
|
81
|
+
Properties routed to `launchOptions`: `headless`, `args`, `executablePath`, `proxy`.
|
|
82
|
+
|
|
83
|
+
Properties routed to `contextOptions`: `viewport`, `userAgent`, `isMobile`, `deviceScaleFactor`, `locale`, `timezoneId`, `permissions`, `geolocation`, `colorScheme`, `ignoreHTTPSErrors`.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## toSwdConfig
|
|
88
|
+
|
|
89
|
+
Translates a `PromodBrowserConfig` into Selenium WebDriver capabilities.
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
const { toSwdConfig } = require('promod');
|
|
93
|
+
|
|
94
|
+
const { browserName, capabilities } = toSwdConfig({
|
|
95
|
+
browserName: 'chrome',
|
|
96
|
+
headless: true,
|
|
97
|
+
viewport: { width: 1280, height: 720 },
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
|
|
103
|
+
| Field | Type | Description |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| `browserName` | `string` | Selenium browser name (`'chrome'`, `'MicrosoftEdge'`, `'firefox'`) |
|
|
106
|
+
| `capabilities` | `object` | Capabilities object for `new Builder().withCapabilities()` |
|
|
107
|
+
|
|
108
|
+
Browser name mapping:
|
|
109
|
+
|
|
110
|
+
| `browserName` | Selenium `browserName` | Capabilities key |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| `'chrome'` | `'chrome'` | `goog:chromeOptions` |
|
|
113
|
+
| `'edge'` | `'MicrosoftEdge'` | `ms:edgeOptions` |
|
|
114
|
+
| `'firefox'` | `'firefox'` | `moz:firefoxOptions` |
|
|
115
|
+
| `'webkit'` | — | throws an error |
|
|
116
|
+
|
|
117
|
+
Property mapping — Chrome / Edge:
|
|
118
|
+
|
|
119
|
+
| Property | Mapping |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `headless` | `args: ['--headless=new']` |
|
|
122
|
+
| `args` | merged into `args` |
|
|
123
|
+
| `executablePath` | `binary` |
|
|
124
|
+
| `proxy` | `--proxy-server=<server>` arg |
|
|
125
|
+
| `viewport` | `--window-size=W,H` arg |
|
|
126
|
+
| `userAgent` | `--user-agent=...` arg + `mobileEmulation.userAgent` |
|
|
127
|
+
| `isMobile` | `mobileEmulation.deviceMetrics.mobile` |
|
|
128
|
+
| `deviceScaleFactor` | `mobileEmulation.deviceMetrics.pixelRatio` |
|
|
129
|
+
| `locale` | `--lang=...` arg |
|
|
130
|
+
| `ignoreHTTPSErrors` | top-level `acceptInsecureCerts: true` |
|
|
131
|
+
| `timezoneId, permissions, geolocation, colorScheme` | not mapped (require CDP at runtime) |
|
|
132
|
+
|
|
133
|
+
Property mapping — Firefox:
|
|
134
|
+
|
|
135
|
+
| Property | Mapping |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `headless` | `args: ['-headless']` |
|
|
138
|
+
| `args` | merged into `args` |
|
|
139
|
+
| `executablePath` | `binary` |
|
|
140
|
+
| `userAgent` | `prefs['general.useragent.override']` |
|
|
141
|
+
| `locale` | `prefs['intl.accept_languages']` |
|
|
142
|
+
| `ignoreHTTPSErrors` | top-level `acceptInsecureCerts: true` |
|
|
143
|
+
| `proxy, viewport, isMobile, deviceScaleFactor` | not mapped (set at runtime) |
|
|
144
|
+
| `timezoneId, permissions, geolocation, colorScheme` | not mapped |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Full example
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
const { chromium, firefox, webkit } = require('playwright');
|
|
152
|
+
const { Builder } = require('selenium-webdriver');
|
|
153
|
+
const { playwrightWD, seleniumWD, toPwConfig, toSwdConfig } = require('promod');
|
|
154
|
+
|
|
155
|
+
const config = {
|
|
156
|
+
browserName: 'chrome',
|
|
157
|
+
headless: true,
|
|
158
|
+
viewport: { width: 1280, height: 720 },
|
|
159
|
+
locale: 'en-US',
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// Playwright
|
|
163
|
+
async function setupPlaywright() {
|
|
164
|
+
const pw = { chromium, firefox, webkit };
|
|
165
|
+
const { browserType, launchOptions, contextOptions } = toPwConfig(config);
|
|
166
|
+
const driver = await pw[browserType].launch(launchOptions);
|
|
167
|
+
playwrightWD.browser.setClient({ driver, baseConfig: contextOptions });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Selenium WebDriver
|
|
171
|
+
async function setupSelenium() {
|
|
172
|
+
const { browserName, capabilities } = toSwdConfig(config);
|
|
173
|
+
const driver = await new Builder().forBrowser(browserName).withCapabilities(capabilities).build();
|
|
174
|
+
seleniumWD.browser.setClient({ driver });
|
|
175
|
+
}
|
|
176
|
+
```
|
package/docs/element.md
CHANGED
|
@@ -1,230 +1,303 @@
|
|
|
1
1
|
# Element
|
|
2
|
-
Element has "lazy" interface (as it was in protractor)
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Element has a "lazy" interface (as it was in protractor). The element is not resolved until an action is performed on it.
|
|
4
|
+
|
|
5
|
+
All examples work identically with both `playwrightWD` and `seleniumWD`.
|
|
6
|
+
|
|
7
|
+
- [Selector strategies](#selector-strategies)
|
|
8
|
+
- [Child elements](#child-elements)
|
|
6
9
|
- [click](#click)
|
|
7
|
-
- [doubleClick](#
|
|
10
|
+
- [doubleClick](#doubleclick)
|
|
11
|
+
- [sendKeys](#sendkeys)
|
|
12
|
+
- [clear](#clear)
|
|
13
|
+
- [clearViaBackspace](#clearViabackspace)
|
|
14
|
+
- [pressEnter](#pressenter)
|
|
8
15
|
- [hover](#hover)
|
|
16
|
+
- [hoverByElementCoordinate](#hoverbyelementcoordinate)
|
|
17
|
+
- [clickByElementCoordinate](#clickbyelementcoordinate)
|
|
18
|
+
- [getElementCoordinates](#getelementcoordinates)
|
|
9
19
|
- [focus](#focus)
|
|
20
|
+
- [getText](#gettext)
|
|
10
21
|
- [getTagName](#gettagname)
|
|
11
|
-
- [getCssValue](#getcssvalue)
|
|
12
22
|
- [getAttribute](#getattribute)
|
|
13
|
-
- [
|
|
23
|
+
- [getCssValue](#getcssvalue)
|
|
14
24
|
- [getRect](#getrect)
|
|
25
|
+
- [isDisplayed](#isdisplayed)
|
|
26
|
+
- [isPresent](#ispresent)
|
|
15
27
|
- [isEnabled](#isenabled)
|
|
16
28
|
- [isSelected](#isselected)
|
|
17
|
-
- [isPresent](#ispresent)
|
|
18
|
-
- [isDisplayed](#isdisplayed)
|
|
19
29
|
- [submit](#submit)
|
|
20
|
-
- [
|
|
21
|
-
- [takeScreenshot](#takescreenshot)
|
|
30
|
+
- [selectOption](#selectoption)
|
|
22
31
|
- [scrollIntoView](#scrollintoview)
|
|
32
|
+
- [takeScreenshot](#takescreenshot)
|
|
33
|
+
- [getEngineElement](#getengineelement)
|
|
34
|
+
- [locator](#locator)
|
|
23
35
|
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Selector strategies
|
|
24
39
|
|
|
25
|
-
## searchStragegy
|
|
26
40
|
```js
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
const { playwrightWD } = require('promod');
|
|
42
|
+
const { $ } = playwrightWD;
|
|
43
|
+
|
|
44
|
+
const byCss = $('.class #id div a[href*="link"]');
|
|
45
|
+
const byXpath = $('xpath=.//div[@data-test="id"]/span');
|
|
46
|
+
const byJS = $(() => document.querySelector('div > span'));
|
|
47
|
+
const byCustom = $({ query: 'button', text: 'Submit' });
|
|
48
|
+
const byCustomRegex = $({ query: 'button', rg: 'Sub.*' });
|
|
30
49
|
```
|
|
31
50
|
|
|
32
|
-
##
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const {$} = seleniumWD
|
|
36
|
-
const someInput = $('input')
|
|
51
|
+
## Child elements
|
|
52
|
+
|
|
53
|
+
Elements can create child `$` and `$$` from themselves, scoping the search to the parent element.
|
|
37
54
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
```js
|
|
56
|
+
const form = $('form');
|
|
57
|
+
const input = form.$('input'); // single child element
|
|
58
|
+
const buttons = form.$$('button'); // child elements collection
|
|
41
59
|
```
|
|
42
60
|
|
|
43
61
|
## click
|
|
62
|
+
|
|
44
63
|
```js
|
|
45
|
-
|
|
46
|
-
const {$} = seleniumWD
|
|
47
|
-
const someButton = $('button')
|
|
64
|
+
const button = $('button');
|
|
48
65
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
66
|
+
await button.click(); // regular click
|
|
67
|
+
await button.click({ withScroll: true }); // scroll into view first
|
|
68
|
+
await button.click({ allowForceIfIntercepted: true }); // retry via coordinates if intercepted
|
|
69
|
+
await button.click({ force: true }); // force click via coordinates
|
|
70
|
+
await button.click({ button: 'right' }); // right click
|
|
52
71
|
```
|
|
53
72
|
|
|
73
|
+
| Option | Type | Description |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| `withScroll` | `boolean` | Scroll element into view before clicking |
|
|
76
|
+
| `allowForceIfIntercepted` | `boolean` | Retry via coordinates if click is intercepted |
|
|
77
|
+
| `force` | `boolean` | Click via coordinates directly |
|
|
78
|
+
| `button` | `'left' \| 'right' \| 'middle'` | Mouse button |
|
|
79
|
+
| `clickCount` | `number` | Number of clicks |
|
|
80
|
+
| `delay` | `number` | Delay between mousedown and mouseup |
|
|
81
|
+
| `modifiers` | `Array<'Alt'\|'Control'\|'Meta'\|'Shift'>` | Modifier keys |
|
|
82
|
+
| `position` | `{ x: number; y: number }` | Click position relative to element |
|
|
83
|
+
| `timeout` | `number` | Timeout in ms |
|
|
84
|
+
|
|
54
85
|
## doubleClick
|
|
86
|
+
|
|
55
87
|
```js
|
|
56
|
-
|
|
57
|
-
const {$} = seleniumWD
|
|
58
|
-
const someButton = $('button')
|
|
88
|
+
const button = $('button');
|
|
59
89
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
90
|
+
await button.doubleClick();
|
|
91
|
+
await button.doubleClick({ withScroll: true });
|
|
63
92
|
```
|
|
64
93
|
|
|
65
|
-
|
|
94
|
+
Accepts the same options as `click` (except `clickCount`).
|
|
95
|
+
|
|
96
|
+
## sendKeys
|
|
97
|
+
|
|
66
98
|
```js
|
|
67
|
-
|
|
68
|
-
const {$} = seleniumWD
|
|
69
|
-
const someButton = $('button')
|
|
99
|
+
const input = $('input');
|
|
70
100
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
await input.sendKeys('hello world');
|
|
102
|
+
await input.sendKeys(42);
|
|
103
|
+
await input.sendKeys('hello', true); // use fill mode (Playwright: clears first then fills)
|
|
74
104
|
```
|
|
75
105
|
|
|
76
|
-
##
|
|
106
|
+
## clear
|
|
107
|
+
|
|
77
108
|
```js
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
109
|
+
const input = $('input');
|
|
110
|
+
await input.clear();
|
|
111
|
+
```
|
|
81
112
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
113
|
+
## clearViaBackspace
|
|
114
|
+
|
|
115
|
+
Clears input by pressing backspace repeatedly.
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
const input = $('input');
|
|
119
|
+
await input.sendKeys('hello');
|
|
120
|
+
await input.clearViaBackspace(5, true); // 5 backspaces, focus first
|
|
85
121
|
```
|
|
86
122
|
|
|
87
|
-
|
|
123
|
+
| Parameter | Type | Description |
|
|
124
|
+
| --- | --- | --- |
|
|
125
|
+
| `repeat` | `number` | Number of backspace presses (default 1) |
|
|
126
|
+
| `focus` | `boolean` | Focus/click element first |
|
|
127
|
+
|
|
128
|
+
## pressEnter
|
|
129
|
+
|
|
88
130
|
```js
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
131
|
+
const input = $('input');
|
|
132
|
+
await input.sendKeys('search query');
|
|
133
|
+
await input.pressEnter(); // focus first (default)
|
|
134
|
+
await input.pressEnter(false); // without focusing
|
|
135
|
+
```
|
|
92
136
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
137
|
+
## hover
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
const button = $('button');
|
|
141
|
+
|
|
142
|
+
await button.hover();
|
|
143
|
+
await button.hover({ force: true });
|
|
96
144
|
```
|
|
97
145
|
|
|
98
|
-
##
|
|
146
|
+
## hoverByElementCoordinate
|
|
147
|
+
|
|
148
|
+
Moves the mouse to a specific position relative to the element.
|
|
149
|
+
|
|
99
150
|
```js
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
151
|
+
const el = $('div');
|
|
152
|
+
await el.hoverByElementCoordinate('center');
|
|
153
|
+
await el.hoverByElementCoordinate('right-top');
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Positions: `'center'`, `'center-top'`, `'center-bottom'`, `'center-right'`, `'center-left'`, `'right-top'`, `'right-bottom'`, `'left-top'`, `'left-bottom'`
|
|
157
|
+
|
|
158
|
+
## clickByElementCoordinate
|
|
103
159
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
160
|
+
Clicks at a specific position relative to the element.
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
const el = $('div');
|
|
164
|
+
await el.clickByElementCoordinate('center');
|
|
165
|
+
await el.clickByElementCoordinate('left-top');
|
|
107
166
|
```
|
|
108
167
|
|
|
109
|
-
##
|
|
168
|
+
## getElementCoordinates
|
|
169
|
+
|
|
170
|
+
Returns the x/y coordinates of a specific position on the element.
|
|
171
|
+
|
|
110
172
|
```js
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const someButton = $('button')
|
|
173
|
+
const { x, y } = await $('div').getElementCoordinates('center');
|
|
174
|
+
```
|
|
114
175
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
176
|
+
## focus
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
const input = $('input');
|
|
180
|
+
await input.focus();
|
|
118
181
|
```
|
|
119
182
|
|
|
120
183
|
## getText
|
|
184
|
+
|
|
121
185
|
```js
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
186
|
+
const text = await $('h1').getText();
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## getTagName
|
|
125
190
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
191
|
+
```js
|
|
192
|
+
const tag = await $('h1').getTagName(); // 'h1'
|
|
129
193
|
```
|
|
130
194
|
|
|
131
|
-
##
|
|
195
|
+
## getAttribute
|
|
196
|
+
|
|
132
197
|
```js
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
198
|
+
const href = await $('a').getAttribute('href');
|
|
199
|
+
const dataId = await $('div').getAttribute('data-id');
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## getCssValue
|
|
136
203
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
204
|
+
Returns the computed CSS property value.
|
|
205
|
+
|
|
206
|
+
```js
|
|
207
|
+
const color = await $('button').getCssValue('color');
|
|
208
|
+
const fontSize = await $('h1').getCssValue('font-size');
|
|
140
209
|
```
|
|
141
210
|
|
|
142
|
-
##
|
|
211
|
+
## getRect
|
|
212
|
+
|
|
213
|
+
Returns the element bounding box.
|
|
214
|
+
|
|
143
215
|
```js
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const someButton = $('button')
|
|
216
|
+
const { x, y, width, height } = await $('div').getRect();
|
|
217
|
+
```
|
|
147
218
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
219
|
+
## isDisplayed
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
const visible = await $('button').isDisplayed(); // true | false
|
|
151
223
|
```
|
|
152
224
|
|
|
153
225
|
## isPresent
|
|
154
|
-
```js
|
|
155
|
-
const {seleniumWD} = require('promod');
|
|
156
|
-
const {$} = seleniumWD
|
|
157
|
-
const someButton = $('button')
|
|
158
226
|
|
|
159
|
-
|
|
160
|
-
const buttonExistsInDOM = await someButton.isPresent() // true|false
|
|
161
|
-
})()
|
|
162
|
-
```
|
|
227
|
+
Checks if the element exists in the DOM.
|
|
163
228
|
|
|
164
|
-
## isDisplayed
|
|
165
229
|
```js
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const someButton = $('button')
|
|
230
|
+
const exists = await $('button').isPresent(); // true | false
|
|
231
|
+
```
|
|
169
232
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
233
|
+
## isEnabled
|
|
234
|
+
|
|
235
|
+
```js
|
|
236
|
+
const enabled = await $('button').isEnabled(); // true | false
|
|
173
237
|
```
|
|
174
238
|
|
|
175
239
|
## isSelected
|
|
176
|
-
```js
|
|
177
|
-
const {seleniumWD} = require('promod');
|
|
178
|
-
const {$} = seleniumWD
|
|
179
|
-
const someButton = $('button')
|
|
180
240
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
})()
|
|
241
|
+
```js
|
|
242
|
+
const selected = await $('input[type="checkbox"]').isSelected(); // true | false
|
|
184
243
|
```
|
|
185
244
|
|
|
186
245
|
## submit
|
|
246
|
+
|
|
247
|
+
```js
|
|
248
|
+
await $('form').submit();
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## selectOption
|
|
252
|
+
|
|
253
|
+
Works with `<select>` elements.
|
|
254
|
+
|
|
187
255
|
```js
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
256
|
+
const select = $('select');
|
|
257
|
+
|
|
258
|
+
// By visible text
|
|
259
|
+
await select.selectOption('Option text');
|
|
260
|
+
|
|
261
|
+
// By value attribute
|
|
262
|
+
await select.selectOption({ value: 'opt1' });
|
|
263
|
+
|
|
264
|
+
// By label attribute
|
|
265
|
+
await select.selectOption({ label: 'Option Label' });
|
|
191
266
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
})()
|
|
267
|
+
// By index
|
|
268
|
+
await select.selectOption({ index: 2 });
|
|
195
269
|
```
|
|
196
270
|
|
|
197
|
-
##
|
|
271
|
+
## scrollIntoView
|
|
272
|
+
|
|
198
273
|
```js
|
|
199
|
-
|
|
200
|
-
const {$} = seleniumWD
|
|
201
|
-
const someInput = $('input')
|
|
274
|
+
const el = $('div');
|
|
202
275
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
276
|
+
await el.scrollIntoView(); // default scroll
|
|
277
|
+
await el.scrollIntoView('start'); // scroll to top of viewport
|
|
278
|
+
await el.scrollIntoView('end'); // scroll to bottom of viewport
|
|
279
|
+
await el.scrollIntoView('center'); // scroll to center of viewport
|
|
280
|
+
await el.scrollIntoView('nearest'); // scroll to nearest edge
|
|
206
281
|
```
|
|
207
282
|
|
|
208
283
|
## takeScreenshot
|
|
209
|
-
```js
|
|
210
|
-
const {seleniumWD} = require('promod');
|
|
211
|
-
const {$} = seleniumWD
|
|
212
|
-
const someForm = $('form')
|
|
213
284
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
})()
|
|
285
|
+
```js
|
|
286
|
+
const screenshot = await $('form').takeScreenshot();
|
|
217
287
|
```
|
|
218
288
|
|
|
219
|
-
##
|
|
289
|
+
## getEngineElement
|
|
290
|
+
|
|
291
|
+
Returns the underlying native engine element (Playwright `Locator` / Selenium `WebElement`).
|
|
292
|
+
|
|
220
293
|
```js
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
294
|
+
const nativeElement = await $('button').getEngineElement();
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## locator
|
|
224
298
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
```
|
|
299
|
+
Returns the selector information used to find this element.
|
|
300
|
+
|
|
301
|
+
```js
|
|
302
|
+
const info = $('button').locator(); // { value: 'button' }
|
|
303
|
+
```
|