@umbraco/playwright-testhelpers 17.0.18 → 17.1.0-beta
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/README.md +139 -29
- package/dist/lib/helpers/BasePage.d.ts +447 -0
- package/dist/lib/helpers/BasePage.js +543 -0
- package/dist/lib/helpers/BasePage.js.map +1 -0
- package/dist/lib/helpers/ConstantHelper.d.ts +17 -0
- package/dist/lib/helpers/ConstantHelper.js +17 -0
- package/dist/lib/helpers/ConstantHelper.js.map +1 -1
- package/dist/lib/helpers/ContentRenderUiHelper.js +3 -3
- package/dist/lib/helpers/ContentRenderUiHelper.js.map +1 -1
- package/dist/lib/helpers/ContentUiHelper.js +312 -442
- package/dist/lib/helpers/ContentUiHelper.js.map +1 -1
- package/dist/lib/helpers/CurrentUserProfileUiHelper.js +4 -10
- package/dist/lib/helpers/CurrentUserProfileUiHelper.js.map +1 -1
- package/dist/lib/helpers/DataTypeUiHelper.js +189 -328
- package/dist/lib/helpers/DataTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/DictionaryUiHelper.js +16 -21
- package/dist/lib/helpers/DictionaryUiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentBlueprintUiHelper.js +7 -8
- package/dist/lib/helpers/DocumentBlueprintUiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentTypeUiHelper.js +18 -33
- package/dist/lib/helpers/DocumentTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/ExamineManagementUiHelper.js +4 -4
- package/dist/lib/helpers/ExamineManagementUiHelper.js.map +1 -1
- package/dist/lib/helpers/FormsUiHelper.js +119 -158
- package/dist/lib/helpers/FormsUiHelper.js.map +1 -1
- package/dist/lib/helpers/HealthCheckUiHelper.js +3 -3
- package/dist/lib/helpers/HealthCheckUiHelper.js.map +1 -1
- package/dist/lib/helpers/LanguageUiHelper.js +15 -17
- package/dist/lib/helpers/LanguageUiHelper.js.map +1 -1
- package/dist/lib/helpers/LogViewerUiHelper.js +20 -29
- package/dist/lib/helpers/LogViewerUiHelper.js.map +1 -1
- package/dist/lib/helpers/LoginUiHelper.js +5 -7
- package/dist/lib/helpers/LoginUiHelper.js.map +1 -1
- package/dist/lib/helpers/MediaTypeUiHelper.js +11 -17
- package/dist/lib/helpers/MediaTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/MediaUiHelper.js +34 -43
- package/dist/lib/helpers/MediaUiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberGroupUiHelper.js +12 -15
- package/dist/lib/helpers/MemberGroupUiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberTypeUiHelper.js +2 -3
- package/dist/lib/helpers/MemberTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberUiHelper.js +24 -42
- package/dist/lib/helpers/MemberUiHelper.js.map +1 -1
- package/dist/lib/helpers/ModelsBuilderUiHelper.js +2 -3
- package/dist/lib/helpers/ModelsBuilderUiHelper.js.map +1 -1
- package/dist/lib/helpers/PackageUiHelper.js +29 -34
- package/dist/lib/helpers/PackageUiHelper.js.map +1 -1
- package/dist/lib/helpers/PartialViewUiHelper.js +13 -15
- package/dist/lib/helpers/PartialViewUiHelper.js.map +1 -1
- package/dist/lib/helpers/ProfilingUiHelper.js +2 -4
- package/dist/lib/helpers/ProfilingUiHelper.js.map +1 -1
- package/dist/lib/helpers/PublishedStatusUiHelper.js +6 -6
- package/dist/lib/helpers/PublishedStatusUiHelper.js.map +1 -1
- package/dist/lib/helpers/RedirectManagementUiHelper.js +7 -12
- package/dist/lib/helpers/RedirectManagementUiHelper.js.map +1 -1
- package/dist/lib/helpers/RelationTypeUiHelper.js +12 -14
- package/dist/lib/helpers/RelationTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/ScriptUiHelper.js +8 -11
- package/dist/lib/helpers/ScriptUiHelper.js.map +1 -1
- package/dist/lib/helpers/StylesheetUiHelper.js +8 -12
- package/dist/lib/helpers/StylesheetUiHelper.js.map +1 -1
- package/dist/lib/helpers/TelemetryDataUiHelper.js +2 -3
- package/dist/lib/helpers/TelemetryDataUiHelper.js.map +1 -1
- package/dist/lib/helpers/TemplateUiHelper.js +17 -22
- package/dist/lib/helpers/TemplateUiHelper.js.map +1 -1
- package/dist/lib/helpers/UiBaseLocators.d.ts +230 -228
- package/dist/lib/helpers/UiBaseLocators.js +832 -869
- package/dist/lib/helpers/UiBaseLocators.js.map +1 -1
- package/dist/lib/helpers/UserGroupUiHelper.js +27 -44
- package/dist/lib/helpers/UserGroupUiHelper.js.map +1 -1
- package/dist/lib/helpers/UserUiHelper.js +42 -45
- package/dist/lib/helpers/UserUiHelper.js.map +1 -1
- package/dist/lib/helpers/WebhookUiHelper.js +11 -27
- package/dist/lib/helpers/WebhookUiHelper.js.map +1 -1
- package/dist/lib/helpers/WelcomeDashboardUiHelper.js +1 -1
- package/dist/lib/helpers/WelcomeDashboardUiHelper.js.map +1 -1
- package/dist/lib/helpers/differentAppSettingsHelpers/ExternalLoginUiHelpers.js +4 -9
- package/dist/lib/helpers/differentAppSettingsHelpers/ExternalLoginUiHelpers.js.map +1 -1
- package/dist/lib/helpers/differentAppSettingsHelpers/InstallUiHelper.js +6 -11
- package/dist/lib/helpers/differentAppSettingsHelpers/InstallUiHelper.js.map +1 -1
- package/dist/lib/helpers/index.d.ts +1 -0
- package/dist/lib/helpers/index.js +3 -1
- package/dist/lib/helpers/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -3
package/README.md
CHANGED
|
@@ -1,48 +1,158 @@
|
|
|
1
|
-
# Umbraco
|
|
2
|
-
|
|
1
|
+
# Umbraco Playwright Test Helpers
|
|
2
|
+
|
|
3
|
+
Test helpers for writing Playwright end-to-end tests for Umbraco CMS.
|
|
4
|
+
|
|
5
|
+
**Repository:** https://github.com/umbraco/umbraco-playwright-testhelpers
|
|
3
6
|
|
|
4
7
|
## Prerequisites
|
|
5
|
-
This project was made with Node V16, so the minimum requirement is node `16.17.1`
|
|
6
|
-
Having playwright installed, you can install playwright by running `npx playwright install`
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
- **Node.js:** Minimum version `16.17.1`
|
|
10
|
+
- **Playwright:** Install via `npx playwright install`
|
|
10
11
|
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @umbraco/playwright-testhelpers
|
|
11
16
|
```
|
|
12
|
-
import { ConstantHelper } from "@umbraco/playwright-testhelpers";
|
|
13
|
-
```
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Basic Test Setup
|
|
21
|
+
|
|
22
|
+
Import the `test` fixture from the package to get access to `umbracoApi` and `umbracoUi` helpers:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { test } from "@umbraco/playwright-testhelpers";
|
|
26
|
+
|
|
27
|
+
test('my test', async ({ umbracoApi, umbracoUi }) => {
|
|
28
|
+
// Your test code here
|
|
29
|
+
});
|
|
16
30
|
```
|
|
17
|
-
|
|
31
|
+
|
|
32
|
+
### API Helpers
|
|
33
|
+
|
|
34
|
+
Use API helpers for test setup, teardown, and backend verification:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { test } from "@umbraco/playwright-testhelpers";
|
|
38
|
+
|
|
39
|
+
test('create document type via API', async ({ umbracoApi }) => {
|
|
40
|
+
const name = 'TestDocType';
|
|
41
|
+
|
|
42
|
+
// Cleanup before test
|
|
43
|
+
await umbracoApi.documentType.ensureNameNotExists(name);
|
|
44
|
+
|
|
45
|
+
// Create via API
|
|
46
|
+
await umbracoApi.documentType.createDefaultDocumentType(name);
|
|
47
|
+
|
|
48
|
+
// Cleanup after test
|
|
49
|
+
await umbracoApi.documentType.ensureNameNotExists(name);
|
|
50
|
+
});
|
|
18
51
|
```
|
|
19
52
|
|
|
20
|
-
|
|
53
|
+
### UI Helpers
|
|
21
54
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
55
|
+
Use UI helpers for browser-based interactions:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { test } from "@umbraco/playwright-testhelpers";
|
|
59
|
+
|
|
60
|
+
test('create content via UI', async ({ umbracoUi }) => {
|
|
61
|
+
await umbracoUi.goToBackOffice();
|
|
62
|
+
await umbracoUi.content.clickActionsMenuAtRoot();
|
|
63
|
+
await umbracoUi.content.clickCreateButton();
|
|
64
|
+
});
|
|
25
65
|
```
|
|
26
|
-
|
|
66
|
+
|
|
67
|
+
### Combined API and UI Testing
|
|
68
|
+
|
|
69
|
+
A common pattern is using API helpers for setup/teardown and UI helpers for the actual test:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import { test } from "@umbraco/playwright-testhelpers";
|
|
73
|
+
|
|
74
|
+
test('edit document type', async ({ umbracoApi, umbracoUi }) => {
|
|
75
|
+
const name = 'TestDocType';
|
|
76
|
+
|
|
77
|
+
// Setup via API
|
|
78
|
+
await umbracoApi.documentType.ensureNameNotExists(name);
|
|
79
|
+
await umbracoApi.documentType.createDefaultDocumentType(name);
|
|
80
|
+
|
|
81
|
+
// Test via UI
|
|
82
|
+
await umbracoUi.goToBackOffice();
|
|
83
|
+
await umbracoUi.documentType.goToDocumentType(name);
|
|
84
|
+
|
|
85
|
+
// Cleanup via API
|
|
86
|
+
await umbracoApi.documentType.ensureNameNotExists(name);
|
|
87
|
+
});
|
|
27
88
|
```
|
|
28
|
-
|
|
89
|
+
|
|
90
|
+
### Constants and Utilities
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { ConstantHelper, AliasHelper, NotificationConstantHelper } from "@umbraco/playwright-testhelpers";
|
|
94
|
+
|
|
95
|
+
// Access UI sections
|
|
96
|
+
const settingsSection = ConstantHelper.sections.settings;
|
|
97
|
+
|
|
98
|
+
// Convert strings to aliases
|
|
99
|
+
const alias = AliasHelper.toAlias('My Document Type'); // 'myDocumentType'
|
|
100
|
+
|
|
101
|
+
// Access notification messages
|
|
102
|
+
const successMsg = NotificationConstantHelper.success.created;
|
|
29
103
|
```
|
|
104
|
+
|
|
105
|
+
## Available Helpers
|
|
106
|
+
|
|
107
|
+
### API Helpers (`umbracoApi.*`)
|
|
108
|
+
|
|
109
|
+
`dataType`, `dictionary`, `document`, `documentBlueprint`, `documentType`, `healthCheck`, `indexer`, `language`, `login`, `logViewer`, `media`, `mediaType`, `member`, `memberGroup`, `memberType`, `modelsBuilder`, `objectTypes`, `package`, `partialView`, `publishedCache`, `redirectManagement`, `relationType`, `script`, `smtp`, `stylesheet`, `telemetry`, `template`, `temporaryFile`, `user`, `userGroup`, `webhook`
|
|
110
|
+
|
|
111
|
+
### UI Helpers (`umbracoUi.*`)
|
|
112
|
+
|
|
113
|
+
`content`, `contentRender`, `currentUserProfile`, `dataType`, `dictionary`, `documentBlueprint`, `documentType`, `examineManagement`, `externalLogin`, `form`, `healthCheck`, `install`, `language`, `login`, `logViewer`, `media`, `mediaType`, `member`, `memberGroup`, `memberType`, `modelsBuilder`, `package`, `partialView`, `profiling`, `publishedStatus`, `redirectManagement`, `relationType`, `script`, `stylesheet`, `telemetryData`, `template`, `user`, `userGroup`, `webhook`, `welcomeDashboard`
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
### Environment Variables
|
|
118
|
+
|
|
119
|
+
| Variable | Description | Default |
|
|
120
|
+
|----------|-------------|---------|
|
|
121
|
+
| `URL` | Umbraco base URL | `https://localhost:44339` |
|
|
122
|
+
| `UMBRACO_USER_LOGIN` | Admin user email | `nge@umbraco.dk` |
|
|
123
|
+
| `UMBRACO_USER_PASSWORD` | Admin user password | `1234567890` |
|
|
124
|
+
| `UMBRACO_MEMBER_LOGIN` | Test member email | `member@example.com` |
|
|
125
|
+
| `UMBRACO_MEMBER_PASSWORD` | Test member password | `Umbraco9Rocks!` |
|
|
126
|
+
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
### Adding New Helpers
|
|
130
|
+
|
|
131
|
+
1. Create your helper file (e.g., `MacroApiHelper.ts`)
|
|
132
|
+
|
|
133
|
+
2. Import and add as a property in `ApiHelpers.ts`:
|
|
134
|
+
```typescript
|
|
135
|
+
import { MacroApiHelper } from "./MacroApiHelper";
|
|
136
|
+
|
|
30
137
|
export class ApiHelpers {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
138
|
+
macro: MacroApiHelper;
|
|
139
|
+
|
|
140
|
+
constructor(page: Page) {
|
|
141
|
+
this.macro = new MacroApiHelper(this);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
34
144
|
```
|
|
35
145
|
|
|
36
|
-
|
|
146
|
+
3. For UI helpers, extend `UiBaseLocators` and add to `UiHelpers.ts`
|
|
37
147
|
|
|
148
|
+
### Testing Changes Locally
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npm run build
|
|
152
|
+
npm pack
|
|
153
|
+
npm i /path/to/umbraco-playwright-testhelpers-x.x.x.tgz
|
|
38
154
|
```
|
|
39
|
-
constructor(page: Page) {
|
|
40
|
-
this.macros = new MacroApiHelper(this);
|
|
41
|
-
...
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
155
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
If you have new changes, you can follow the same steps as before.
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { Locator, Page } from "@playwright/test";
|
|
2
|
+
/**
|
|
3
|
+
* Base page class providing common UI interaction methods.
|
|
4
|
+
* All methods follow best practices for reliability:
|
|
5
|
+
* - click: Always checks element visibility before clicking
|
|
6
|
+
* - enterText: Always clears before filling text
|
|
7
|
+
* - select: Waits for element visibility before selecting
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* class MyPage extends BasePage {
|
|
12
|
+
* readonly submitBtn: Locator;
|
|
13
|
+
*
|
|
14
|
+
* constructor(page: Page) {
|
|
15
|
+
* super(page);
|
|
16
|
+
* this.submitBtn = page.getByRole('button', { name: 'Submit' });
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* async submit() {
|
|
20
|
+
* await this.click(this.submitBtn);
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class BasePage {
|
|
26
|
+
readonly page: Page;
|
|
27
|
+
constructor(page: Page);
|
|
28
|
+
/**
|
|
29
|
+
* Clicks an element after verifying it is visible.
|
|
30
|
+
* @param locator - The element to click
|
|
31
|
+
* @param options - Optional click configuration
|
|
32
|
+
*/
|
|
33
|
+
click(locator: Locator, options?: {
|
|
34
|
+
force?: boolean;
|
|
35
|
+
timeout?: number;
|
|
36
|
+
}): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Double-clicks an element after verifying it is visible.
|
|
39
|
+
* @param locator - The element to double-click
|
|
40
|
+
* @param options - Optional configuration
|
|
41
|
+
*/
|
|
42
|
+
doubleClick(locator: Locator, options?: {
|
|
43
|
+
force?: boolean;
|
|
44
|
+
timeout?: number;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Right-clicks an element after verifying it is visible.
|
|
48
|
+
* @param locator - The element to right-click
|
|
49
|
+
* @param options - Optional configuration
|
|
50
|
+
*/
|
|
51
|
+
rightClick(locator: Locator, options?: {
|
|
52
|
+
force?: boolean;
|
|
53
|
+
timeout?: number;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Clicks an element using JavaScript (bypasses actionability checks).
|
|
57
|
+
* Use when standard click doesn't work due to overlapping elements.
|
|
58
|
+
* @param locator - The element to click
|
|
59
|
+
*/
|
|
60
|
+
forceClick(locator: Locator): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Enters text into an input field after clearing it.
|
|
63
|
+
* Verifies element visibility before interaction.
|
|
64
|
+
* @param locator - The input element
|
|
65
|
+
* @param text - The text to enter
|
|
66
|
+
* @param options - Optional configuration
|
|
67
|
+
*/
|
|
68
|
+
enterText(locator: Locator, text: string, options?: {
|
|
69
|
+
clearFirst?: boolean;
|
|
70
|
+
verify?: boolean;
|
|
71
|
+
timeout?: number;
|
|
72
|
+
}): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Types text character by character (simulates real typing).
|
|
75
|
+
* Useful when fill() doesn't trigger necessary events.
|
|
76
|
+
* @param locator - The input element
|
|
77
|
+
* @param text - The text to type
|
|
78
|
+
* @param options - Optional configuration
|
|
79
|
+
*/
|
|
80
|
+
typeText(locator: Locator, text: string, options?: {
|
|
81
|
+
clearFirst?: boolean;
|
|
82
|
+
delay?: number;
|
|
83
|
+
timeout?: number;
|
|
84
|
+
}): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Clears an input field.
|
|
87
|
+
* @param locator - The input element to clear
|
|
88
|
+
*/
|
|
89
|
+
clearText(locator: Locator, options?: {
|
|
90
|
+
timeout?: number;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Presses a keyboard key while focused on an element.
|
|
94
|
+
* @param locator - The element to focus
|
|
95
|
+
* @param key - The key to press (e.g., 'Enter', 'Tab', 'Escape')
|
|
96
|
+
*/
|
|
97
|
+
pressKey(locator: Locator, key: string, options?: {
|
|
98
|
+
timeout?: number;
|
|
99
|
+
}): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Selects an option from a dropdown by value.
|
|
102
|
+
* @param locator - The select element
|
|
103
|
+
* @param value - The option value to select
|
|
104
|
+
*/
|
|
105
|
+
selectByValue(locator: Locator, value: string, options?: {
|
|
106
|
+
timeout?: number;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Selects an option from a dropdown by visible text.
|
|
110
|
+
* @param locator - The select element
|
|
111
|
+
* @param text - The option text to select
|
|
112
|
+
*/
|
|
113
|
+
selectByText(locator: Locator, text: string, options?: {
|
|
114
|
+
timeout?: number;
|
|
115
|
+
}): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Selects an option from a dropdown by index.
|
|
118
|
+
* @param locator - The select element
|
|
119
|
+
* @param index - The option index to select (0-based)
|
|
120
|
+
*/
|
|
121
|
+
selectByIndex(locator: Locator, index: number, options?: {
|
|
122
|
+
timeout?: number;
|
|
123
|
+
}): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Selects multiple options from a multi-select dropdown.
|
|
126
|
+
* @param locator - The select element
|
|
127
|
+
* @param values - Array of option values to select
|
|
128
|
+
*/
|
|
129
|
+
selectMultiple(locator: Locator, values: string[], options?: {
|
|
130
|
+
timeout?: number;
|
|
131
|
+
}): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Checks a checkbox if it's not already checked.
|
|
134
|
+
* @param locator - The checkbox element
|
|
135
|
+
*/
|
|
136
|
+
check(locator: Locator, options?: {
|
|
137
|
+
force?: boolean;
|
|
138
|
+
timeout?: number;
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Unchecks a checkbox if it's currently checked.
|
|
142
|
+
* @param locator - The checkbox element
|
|
143
|
+
*/
|
|
144
|
+
uncheck(locator: Locator, options?: {
|
|
145
|
+
force?: boolean;
|
|
146
|
+
timeout?: number;
|
|
147
|
+
}): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Sets a checkbox to a specific state.
|
|
150
|
+
* @param locator - The checkbox element
|
|
151
|
+
* @param checked - Whether the checkbox should be checked
|
|
152
|
+
*/
|
|
153
|
+
setChecked(locator: Locator, checked: boolean, options?: {
|
|
154
|
+
force?: boolean;
|
|
155
|
+
timeout?: number;
|
|
156
|
+
}): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Hovers over an element.
|
|
159
|
+
* @param locator - The element to hover over
|
|
160
|
+
*/
|
|
161
|
+
hover(locator: Locator, options?: {
|
|
162
|
+
force?: boolean;
|
|
163
|
+
timeout?: number;
|
|
164
|
+
}): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Focuses on an element.
|
|
167
|
+
* @param locator - The element to focus
|
|
168
|
+
*/
|
|
169
|
+
focus(locator: Locator, options?: {
|
|
170
|
+
timeout?: number;
|
|
171
|
+
}): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Hovers over one element and clicks another (for menus that appear on hover).
|
|
174
|
+
* @param hoverLocator - The element to hover over
|
|
175
|
+
* @param clickLocator - The element to click after hover
|
|
176
|
+
*/
|
|
177
|
+
hoverAndClick(hoverLocator: Locator, clickLocator: Locator, options?: {
|
|
178
|
+
force?: boolean;
|
|
179
|
+
timeout?: number;
|
|
180
|
+
}): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Waits for an element to be visible.
|
|
183
|
+
* @param locator - The element to wait for
|
|
184
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
185
|
+
*/
|
|
186
|
+
waitForVisible(locator: Locator, timeout?: number): Promise<void>;
|
|
187
|
+
/**
|
|
188
|
+
* Waits for an element to be hidden.
|
|
189
|
+
* @param locator - The element to wait for
|
|
190
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
191
|
+
*/
|
|
192
|
+
waitForHidden(locator: Locator, timeout?: number): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Waits for an element to be attached to the DOM.
|
|
195
|
+
* @param locator - The element to wait for
|
|
196
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
197
|
+
*/
|
|
198
|
+
waitForAttached(locator: Locator, timeout?: number): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* Waits for an element to be detached from the DOM.
|
|
201
|
+
* @param locator - The element to wait for
|
|
202
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
203
|
+
*/
|
|
204
|
+
waitForDetached(locator: Locator, timeout?: number): Promise<void>;
|
|
205
|
+
/**
|
|
206
|
+
* Waits for the page to finish loading (network idle).
|
|
207
|
+
*/
|
|
208
|
+
waitForPageLoad(): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Waits for the DOM to be fully loaded.
|
|
211
|
+
*/
|
|
212
|
+
waitForDOMContentLoaded(): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* Waits for all network requests to complete.
|
|
215
|
+
*/
|
|
216
|
+
waitForLoadState(): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Waits for an element to be enabled.
|
|
219
|
+
* @param locator - The element to wait for
|
|
220
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
221
|
+
*/
|
|
222
|
+
waitForEnabled(locator: Locator, timeout?: number): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Waits for an element to be disabled.
|
|
225
|
+
* @param locator - The element to wait for
|
|
226
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
227
|
+
*/
|
|
228
|
+
waitForDisabled(locator: Locator, timeout?: number): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Waits for an element to contain specific text.
|
|
231
|
+
* @param locator - The element to wait for
|
|
232
|
+
* @param text - The text to wait for
|
|
233
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
234
|
+
*/
|
|
235
|
+
waitForText(locator: Locator, text: string, timeout?: number): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Waits for an input to have a specific value.
|
|
238
|
+
* @param locator - The input element to wait for
|
|
239
|
+
* @param value - The value to wait for
|
|
240
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
241
|
+
*/
|
|
242
|
+
waitForValue(locator: Locator, value: string, timeout?: number): Promise<void>;
|
|
243
|
+
/**
|
|
244
|
+
* Waits for an element to have a specific attribute value.
|
|
245
|
+
* @param locator - The element to wait for
|
|
246
|
+
* @param name - The attribute name
|
|
247
|
+
* @param value - The expected attribute value
|
|
248
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
249
|
+
*/
|
|
250
|
+
waitForAttribute(locator: Locator, name: string, value: string | RegExp, timeout?: number): Promise<void>;
|
|
251
|
+
/**
|
|
252
|
+
* Waits for an element to have a specific CSS class.
|
|
253
|
+
* @param locator - The element to wait for
|
|
254
|
+
* @param className - The CSS class to wait for
|
|
255
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
256
|
+
*/
|
|
257
|
+
waitForClass(locator: Locator, className: string | RegExp, timeout?: number): Promise<void>;
|
|
258
|
+
/**
|
|
259
|
+
* Waits for an element to be editable.
|
|
260
|
+
* @param locator - The element to wait for
|
|
261
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
262
|
+
*/
|
|
263
|
+
waitForEditable(locator: Locator, timeout?: number): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Waits for an element to be checked.
|
|
266
|
+
* @param locator - The checkbox/radio element to wait for
|
|
267
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
268
|
+
*/
|
|
269
|
+
waitForChecked(locator: Locator, timeout?: number): Promise<void>;
|
|
270
|
+
/**
|
|
271
|
+
* Waits for an element to be unchecked.
|
|
272
|
+
* @param locator - The checkbox/radio element to wait for
|
|
273
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
274
|
+
*/
|
|
275
|
+
waitForUnchecked(locator: Locator, timeout?: number): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Waits for a specific URL or URL pattern.
|
|
278
|
+
* @param url - The URL string or regex pattern to wait for
|
|
279
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
280
|
+
*/
|
|
281
|
+
waitForURL(url: string | RegExp, timeout?: number): Promise<void>;
|
|
282
|
+
/**
|
|
283
|
+
* Waits for a navigation to complete.
|
|
284
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
285
|
+
*/
|
|
286
|
+
waitForNavigation(timeout?: number): Promise<void>;
|
|
287
|
+
/**
|
|
288
|
+
* Waits for a specific time (use sparingly, prefer explicit waits).
|
|
289
|
+
* @param milliseconds - Time to wait in milliseconds
|
|
290
|
+
*/
|
|
291
|
+
waitForTimeout(milliseconds: number): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Waits for a network request to a specific URL.
|
|
294
|
+
* @param urlOrPredicate - URL string, regex, or predicate function
|
|
295
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
296
|
+
*/
|
|
297
|
+
waitForRequest(urlOrPredicate: string | RegExp | ((request: any) => boolean), timeout?: number): Promise<any>;
|
|
298
|
+
/**
|
|
299
|
+
* Waits for a network response from a specific URL.
|
|
300
|
+
* @param urlOrPredicate - URL string, regex, or predicate function
|
|
301
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
302
|
+
*/
|
|
303
|
+
waitForResponse(urlOrPredicate: string | RegExp | ((response: any) => boolean), timeout?: number): Promise<any>;
|
|
304
|
+
/**
|
|
305
|
+
* Waits for an element to be focused.
|
|
306
|
+
* @param locator - The element to wait for
|
|
307
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
308
|
+
*/
|
|
309
|
+
waitForFocused(locator: Locator, timeout?: number): Promise<void>;
|
|
310
|
+
/**
|
|
311
|
+
* Waits for an element to be empty (no text content).
|
|
312
|
+
* @param locator - The element to wait for
|
|
313
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
314
|
+
*/
|
|
315
|
+
waitForEmpty(locator: Locator, timeout?: number): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* Waits for a function to return true.
|
|
318
|
+
* @param predicate - Function that returns a boolean or Promise<boolean>
|
|
319
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
320
|
+
*/
|
|
321
|
+
waitForFunction(predicate: () => boolean | Promise<boolean>, timeout?: number): Promise<void>;
|
|
322
|
+
/**
|
|
323
|
+
* Waits for an element to have a specific CSS property value.
|
|
324
|
+
* @param locator - The element to wait for
|
|
325
|
+
* @param property - The CSS property name
|
|
326
|
+
* @param value - The expected CSS property value
|
|
327
|
+
* @param timeout - Maximum time to wait in milliseconds
|
|
328
|
+
*/
|
|
329
|
+
waitForCSS(locator: Locator, property: string, value: string | RegExp, timeout?: number): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Asserts that an element is visible.
|
|
332
|
+
* @param locator - The element to check
|
|
333
|
+
* @param isVisible - Whether the element should be visible (default: true)
|
|
334
|
+
*/
|
|
335
|
+
isVisible(locator: Locator, isVisible?: boolean, timeout?: number): Promise<void>;
|
|
336
|
+
/**
|
|
337
|
+
* Asserts that an element is enabled.
|
|
338
|
+
* @param locator - The element to check
|
|
339
|
+
*/
|
|
340
|
+
isEnabled(locator: Locator, timeout?: number): Promise<void>;
|
|
341
|
+
/**
|
|
342
|
+
* Asserts that an element is disabled.
|
|
343
|
+
* @param locator - The element to check
|
|
344
|
+
*/
|
|
345
|
+
isDisabled(locator: Locator, timeout?: number): Promise<void>;
|
|
346
|
+
/**
|
|
347
|
+
* Asserts that an element contains specific text.
|
|
348
|
+
* @param locator - The element to check
|
|
349
|
+
* @param text - The text to look for
|
|
350
|
+
*/
|
|
351
|
+
containsText(locator: Locator, text: string, timeout?: number): Promise<void>;
|
|
352
|
+
/**
|
|
353
|
+
* Asserts that an element has specific text.
|
|
354
|
+
* @param locator - The element to check
|
|
355
|
+
* @param text - The exact text expected
|
|
356
|
+
*/
|
|
357
|
+
hasText(locator: Locator, text: string, timeout?: number): Promise<void>;
|
|
358
|
+
/**
|
|
359
|
+
* Asserts that an input has a specific value.
|
|
360
|
+
* @param locator - The input element to check
|
|
361
|
+
* @param value - The expected value
|
|
362
|
+
*/
|
|
363
|
+
hasValue(locator: Locator, value: string, timeout?: number): Promise<void>;
|
|
364
|
+
/**
|
|
365
|
+
* Asserts that an element has a specific attribute value.
|
|
366
|
+
* @param locator - The element to check
|
|
367
|
+
* @param name - The attribute name
|
|
368
|
+
* @param value - The expected attribute value
|
|
369
|
+
*/
|
|
370
|
+
hasAttribute(locator: Locator, name: string, value: string, timeout?: number): Promise<void>;
|
|
371
|
+
/**
|
|
372
|
+
* Asserts that a specific number of elements exist.
|
|
373
|
+
* @param locator - The locator to count
|
|
374
|
+
* @param count - The expected count
|
|
375
|
+
*/
|
|
376
|
+
hasCount(locator: Locator, count: number, timeout?: number): Promise<void>;
|
|
377
|
+
/**
|
|
378
|
+
* Gets the text content of an element.
|
|
379
|
+
* @param locator - The element to get text from
|
|
380
|
+
* @returns The text content
|
|
381
|
+
*/
|
|
382
|
+
getText(locator: Locator, options?: {
|
|
383
|
+
timeout?: number;
|
|
384
|
+
}): Promise<string>;
|
|
385
|
+
/**
|
|
386
|
+
* Gets the value of an input element.
|
|
387
|
+
* @param locator - The input element
|
|
388
|
+
* @returns The input value
|
|
389
|
+
*/
|
|
390
|
+
getValue(locator: Locator, options?: {
|
|
391
|
+
timeout?: number;
|
|
392
|
+
}): Promise<string>;
|
|
393
|
+
/**
|
|
394
|
+
* Gets an attribute value from an element.
|
|
395
|
+
* @param locator - The element
|
|
396
|
+
* @param attributeName - The attribute name
|
|
397
|
+
* @returns The attribute value or null
|
|
398
|
+
*/
|
|
399
|
+
getAttribute(locator: Locator, attributeName: string, options?: {
|
|
400
|
+
timeout?: number;
|
|
401
|
+
}): Promise<string | null>;
|
|
402
|
+
/**
|
|
403
|
+
* Checks if an element is currently visible.
|
|
404
|
+
* @param locator - The element to check
|
|
405
|
+
* @returns True if visible, false otherwise
|
|
406
|
+
*/
|
|
407
|
+
checkIsVisible(locator: Locator): Promise<boolean>;
|
|
408
|
+
/**
|
|
409
|
+
* Checks if a checkbox is checked.
|
|
410
|
+
* @param locator - The checkbox element
|
|
411
|
+
* @returns True if checked, false otherwise
|
|
412
|
+
*/
|
|
413
|
+
isChecked(locator: Locator): Promise<boolean>;
|
|
414
|
+
/**
|
|
415
|
+
* Scrolls an element into view.
|
|
416
|
+
* @param locator - The element to scroll to
|
|
417
|
+
*/
|
|
418
|
+
scrollIntoView(locator: Locator, options?: {
|
|
419
|
+
timeout?: number;
|
|
420
|
+
}): Promise<void>;
|
|
421
|
+
/**
|
|
422
|
+
* Sets files on a file input element.
|
|
423
|
+
* @param locator - The file input element
|
|
424
|
+
* @param filePath - Path to the file(s) to set
|
|
425
|
+
*/
|
|
426
|
+
setInputFiles(locator: Locator, filePath: string | string[]): Promise<void>;
|
|
427
|
+
/**
|
|
428
|
+
* Clears files from a file input.
|
|
429
|
+
* @param locator - The file input element
|
|
430
|
+
*/
|
|
431
|
+
clearInputFiles(locator: Locator): Promise<void>;
|
|
432
|
+
/**
|
|
433
|
+
* Drags an element and drops it on another element.
|
|
434
|
+
* @param source - The element to drag
|
|
435
|
+
* @param target - The element to drop on
|
|
436
|
+
*/
|
|
437
|
+
dragTo(source: Locator, target: Locator, options?: {
|
|
438
|
+
sourcePosition?: {
|
|
439
|
+
x: number;
|
|
440
|
+
y: number;
|
|
441
|
+
};
|
|
442
|
+
targetPosition?: {
|
|
443
|
+
x: number;
|
|
444
|
+
y: number;
|
|
445
|
+
};
|
|
446
|
+
}): Promise<void>;
|
|
447
|
+
}
|