@dream_engine/browser 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/adapter/playwright.d.ts +27 -0
- package/dist/adapter/playwright.d.ts.map +1 -0
- package/dist/adapter/playwright.js +1087 -0
- package/dist/adapter/playwright.js.map +1 -0
- package/dist/adapter/types.d.ts +833 -0
- package/dist/adapter/types.d.ts.map +1 -0
- package/dist/adapter/types.js +9 -0
- package/dist/adapter/types.js.map +1 -0
- package/dist/api-request.d.ts +93 -0
- package/dist/api-request.d.ts.map +1 -0
- package/dist/api-request.js +284 -0
- package/dist/api-request.js.map +1 -0
- package/dist/artifacts.d.ts +99 -0
- package/dist/artifacts.d.ts.map +1 -0
- package/dist/artifacts.js +211 -0
- package/dist/artifacts.js.map +1 -0
- package/dist/browser.d.ts +79 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +186 -0
- package/dist/browser.js.map +1 -0
- package/dist/code-execution.d.ts +12 -0
- package/dist/code-execution.d.ts.map +1 -0
- package/dist/code-execution.js +15 -0
- package/dist/code-execution.js.map +1 -0
- package/dist/context.d.ts +174 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +474 -0
- package/dist/context.js.map +1 -0
- package/dist/events.d.ts +66 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +87 -0
- package/dist/events.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/locator.d.ts +208 -0
- package/dist/locator.d.ts.map +1 -0
- package/dist/locator.js +402 -0
- package/dist/locator.js.map +1 -0
- package/dist/login.d.ts +76 -0
- package/dist/login.d.ts.map +1 -0
- package/dist/login.js +176 -0
- package/dist/login.js.map +1 -0
- package/dist/manager.d.ts +109 -0
- package/dist/manager.d.ts.map +1 -0
- package/dist/manager.js +320 -0
- package/dist/manager.js.map +1 -0
- package/dist/navigation.d.ts +74 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +234 -0
- package/dist/navigation.js.map +1 -0
- package/dist/network.d.ts +260 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +582 -0
- package/dist/network.js.map +1 -0
- package/dist/page.d.ts +512 -0
- package/dist/page.d.ts.map +1 -0
- package/dist/page.js +1493 -0
- package/dist/page.js.map +1 -0
- package/dist/selectors.d.ts +67 -0
- package/dist/selectors.d.ts.map +1 -0
- package/dist/selectors.js +137 -0
- package/dist/selectors.js.map +1 -0
- package/dist/sessions.d.ts +114 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/sessions.js +285 -0
- package/dist/sessions.js.map +1 -0
- package/dist/smart/dom-scan.d.ts +104 -0
- package/dist/smart/dom-scan.d.ts.map +1 -0
- package/dist/smart/dom-scan.js +491 -0
- package/dist/smart/dom-scan.js.map +1 -0
- package/dist/smart/ranking.d.ts +63 -0
- package/dist/smart/ranking.d.ts.map +1 -0
- package/dist/smart/ranking.js +318 -0
- package/dist/smart/ranking.js.map +1 -0
- package/dist/smart/recovery.d.ts +106 -0
- package/dist/smart/recovery.d.ts.map +1 -0
- package/dist/smart/recovery.js +197 -0
- package/dist/smart/recovery.js.map +1 -0
- package/dist/smart/smart.d.ts +249 -0
- package/dist/smart/smart.d.ts.map +1 -0
- package/dist/smart/smart.js +840 -0
- package/dist/smart/smart.js.map +1 -0
- package/dist/trace-parser.d.ts +70 -0
- package/dist/trace-parser.d.ts.map +1 -0
- package/dist/trace-parser.js +203 -0
- package/dist/trace-parser.js.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/visual.d.ts +185 -0
- package/dist/visual.d.ts.map +1 -0
- package/dist/visual.js +384 -0
- package/dist/visual.js.map +1 -0
- package/package.json +37 -3
- package/README.md +0 -3
package/dist/locator.js
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import { AmbiguousElementError, BashirWebError, ElementNotFoundError, InteractionError, TimeoutError, ValidationError } from '@dream_engine/core';
|
|
2
|
+
import { by } from './selectors.js';
|
|
3
|
+
const GUARDED = new Set(['click', 'dblclick', 'tap', 'press', 'check', 'uncheck', 'setChecked', 'dispatchEvent']);
|
|
4
|
+
const ENTER_FRAME = 'internal:control=enter-frame';
|
|
5
|
+
/** Converts Playwright's untyped errors into BashirWeb's typed errors. */
|
|
6
|
+
export function toLocatorError(error, action, selector) {
|
|
7
|
+
if (error instanceof BashirWebError)
|
|
8
|
+
return error;
|
|
9
|
+
const e = error;
|
|
10
|
+
const message = (e?.message ?? String(error)).split('\n')[0] ?? '';
|
|
11
|
+
const details = { selector, action };
|
|
12
|
+
if (/strict mode violation/i.test(message)) {
|
|
13
|
+
const count = /resolved to (\d+) elements/.exec(e.message)?.[1];
|
|
14
|
+
return new AmbiguousElementError(`Selector "${selector}" matches ${count ?? 'several'} elements; narrow it or use first()/nth()`, {
|
|
15
|
+
cause: error,
|
|
16
|
+
details: { ...details, ...(count ? { count: Number(count) } : {}) },
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (e?.name === 'TimeoutError' || /Timeout \d+ms exceeded/.test(message))
|
|
20
|
+
return new TimeoutError(`${action} on "${selector}" timed out`, { cause: error, details });
|
|
21
|
+
if (/Element is not attached|element\(s\) not found|No element/i.test(message))
|
|
22
|
+
return new ElementNotFoundError(`No element matches selector "${selector}"`, { cause: error, details });
|
|
23
|
+
return new InteractionError(`${action} on "${selector}" failed: ${message}`, { cause: error, details });
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A lazy, re-resolving element query with Playwright's locator semantics: strict (actions throw
|
|
27
|
+
* `AmbiguousElementError` when several elements match), auto-waiting, and composable with
|
|
28
|
+
* `filter`, `and`, `or`, `nth`, `getBy*` and `frameLocator`.
|
|
29
|
+
*
|
|
30
|
+
* It also implements the engine-neutral `LocatorAdapter` interface, so existing code that used
|
|
31
|
+
* `page.locator()` results keeps working.
|
|
32
|
+
*/
|
|
33
|
+
/** Engine locators behind BashirLocators; module-private so callers can't bypass guards and gates. */
|
|
34
|
+
const RAW = new WeakMap();
|
|
35
|
+
/** @internal Returns the engine-level locator for a BashirLocator (or the adapter itself). */
|
|
36
|
+
export function unwrapLocator(locator) {
|
|
37
|
+
return RAW.get(locator) ?? locator;
|
|
38
|
+
}
|
|
39
|
+
export class BashirLocator {
|
|
40
|
+
scope;
|
|
41
|
+
selector;
|
|
42
|
+
host;
|
|
43
|
+
rawLocator;
|
|
44
|
+
constructor(scope, selector, host) {
|
|
45
|
+
this.scope = scope;
|
|
46
|
+
this.selector = selector;
|
|
47
|
+
this.host = host;
|
|
48
|
+
if (typeof selector !== 'string' || !selector.trim())
|
|
49
|
+
throw new ValidationError('Selector must be a non-empty string');
|
|
50
|
+
this.rawLocator = scope.locator(selector);
|
|
51
|
+
RAW.set(this, this.rawLocator);
|
|
52
|
+
}
|
|
53
|
+
derive(selector) {
|
|
54
|
+
return new BashirLocator(this.scope, selector, this.host);
|
|
55
|
+
}
|
|
56
|
+
// ---- composition --------------------------------------------------------------------------
|
|
57
|
+
/** Finds `selector` (or the elements of another locator) inside the matched elements. */
|
|
58
|
+
locator(selectorOrLocator, options = {}) {
|
|
59
|
+
const inner = typeof selectorOrLocator === 'string' ? selectorOrLocator : selectorOrLocator.selector;
|
|
60
|
+
const base = this.derive(`${this.selector} >> ${inner}`);
|
|
61
|
+
return Object.keys(options).length ? base.filter(options) : base;
|
|
62
|
+
}
|
|
63
|
+
getByRole(role, options = {}) {
|
|
64
|
+
return this.locator(by.role(role, options));
|
|
65
|
+
}
|
|
66
|
+
getByText(text, options = {}) {
|
|
67
|
+
return this.locator(by.text(text, options));
|
|
68
|
+
}
|
|
69
|
+
getByLabel(text, options = {}) {
|
|
70
|
+
return this.locator(by.label(text, options));
|
|
71
|
+
}
|
|
72
|
+
getByPlaceholder(text, options = {}) {
|
|
73
|
+
return this.locator(by.placeholder(text, options));
|
|
74
|
+
}
|
|
75
|
+
getByAltText(text, options = {}) {
|
|
76
|
+
return this.locator(by.altText(text, options));
|
|
77
|
+
}
|
|
78
|
+
getByTitle(text, options = {}) {
|
|
79
|
+
return this.locator(by.title(text, options));
|
|
80
|
+
}
|
|
81
|
+
getByTestId(id) {
|
|
82
|
+
return this.locator(testIdSelector(id, this.host.testIdAttribute()));
|
|
83
|
+
}
|
|
84
|
+
/** Narrows the matches by text, by descendants (`has`/`hasNot`) or by visibility. */
|
|
85
|
+
filter(options) {
|
|
86
|
+
const { has, hasNot, ...rest } = options;
|
|
87
|
+
for (const [k, v] of [
|
|
88
|
+
['has', has],
|
|
89
|
+
['hasNot', hasNot],
|
|
90
|
+
])
|
|
91
|
+
if (v !== undefined && !(v instanceof BashirLocator))
|
|
92
|
+
throw new ValidationError(`filter({ ${k} }) needs a locator`);
|
|
93
|
+
return this.derive(by.filter(this.selector, {
|
|
94
|
+
...rest,
|
|
95
|
+
...(has ? { has: has.selector } : {}),
|
|
96
|
+
...(hasNot ? { hasNot: hasNot.selector } : {}),
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
/** Elements that match both this locator and `other`. */
|
|
100
|
+
and(other) {
|
|
101
|
+
return this.derive(by.and(this.selector, other.selector));
|
|
102
|
+
}
|
|
103
|
+
/** Elements that match either this locator or `other`. */
|
|
104
|
+
or(other) {
|
|
105
|
+
return this.derive(by.or(this.selector, other.selector));
|
|
106
|
+
}
|
|
107
|
+
first() {
|
|
108
|
+
return this.derive(by.first(this.selector));
|
|
109
|
+
}
|
|
110
|
+
last() {
|
|
111
|
+
return this.derive(by.last(this.selector));
|
|
112
|
+
}
|
|
113
|
+
nth(index) {
|
|
114
|
+
return this.derive(by.nth(this.selector, index));
|
|
115
|
+
}
|
|
116
|
+
/** One locator per element currently matched (does not wait). */
|
|
117
|
+
async all() {
|
|
118
|
+
const n = await this.count();
|
|
119
|
+
return Array.from({ length: n }, (_, i) => this.nth(i));
|
|
120
|
+
}
|
|
121
|
+
/** Locator for an iframe inside the matched elements. */
|
|
122
|
+
frameLocator(selector) {
|
|
123
|
+
return new BashirFrameLocator(this.scope, `${this.selector} >> ${selector}`, this.host);
|
|
124
|
+
}
|
|
125
|
+
/** Treats the matched `<iframe>` as a frame and locates inside it. */
|
|
126
|
+
contentFrame() {
|
|
127
|
+
return new BashirFrameLocator(this.scope, this.selector, this.host);
|
|
128
|
+
}
|
|
129
|
+
// ---- actions ------------------------------------------------------------------------------
|
|
130
|
+
async run(action, options, fn, activationKey) {
|
|
131
|
+
this.host.assertUsable();
|
|
132
|
+
const timeout = options.timeout ?? this.host.defaultTimeout();
|
|
133
|
+
const guard = options.guardConsequential ?? this.host.guardByDefault();
|
|
134
|
+
try {
|
|
135
|
+
if (guard && GUARDED.has(action))
|
|
136
|
+
await this.host.guard(action, this.selector, this.rawLocator, activationKey);
|
|
137
|
+
return await fn(timeout);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const e = toLocatorError(error, action, this.selector);
|
|
141
|
+
this.host.emitFailure(action, this.selector, e.message);
|
|
142
|
+
throw e;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async click(options = {}) {
|
|
146
|
+
const { timeout: _t, guardConsequential: _g, ...rest } = options;
|
|
147
|
+
await this.run('click', options, (timeout) => this.rawLocator.click({ ...rest, timeout }));
|
|
148
|
+
this.host.emit('element:clicked', this.selector);
|
|
149
|
+
}
|
|
150
|
+
async dblclick(options = {}) {
|
|
151
|
+
await this.run('dblclick', options, (timeout) => this.rawLocator.dblclick({ timeout }));
|
|
152
|
+
this.host.emit('element:clicked', this.selector);
|
|
153
|
+
}
|
|
154
|
+
async hover(options = {}) {
|
|
155
|
+
return this.run('hover', options, (timeout) => this.rawLocator.hover({ timeout }));
|
|
156
|
+
}
|
|
157
|
+
async tap(options = {}) {
|
|
158
|
+
return this.run('tap', options, (timeout) => this.rawLocator.tap({ timeout }));
|
|
159
|
+
}
|
|
160
|
+
async focus(options = {}) {
|
|
161
|
+
return this.run('focus', options, (timeout) => this.rawLocator.focus({ timeout }));
|
|
162
|
+
}
|
|
163
|
+
async blur(options = {}) {
|
|
164
|
+
return this.run('blur', options, (timeout) => this.rawLocator.blur({ timeout }));
|
|
165
|
+
}
|
|
166
|
+
async fill(value, options = {}) {
|
|
167
|
+
if (typeof value !== 'string')
|
|
168
|
+
throw new ValidationError('fill() value must be a string');
|
|
169
|
+
await this.run('fill', options, (timeout) => this.rawLocator.fill(value, { timeout }));
|
|
170
|
+
this.host.emit('element:filled', this.selector);
|
|
171
|
+
}
|
|
172
|
+
async clear(options = {}) {
|
|
173
|
+
return this.run('clear', options, (timeout) => this.rawLocator.clear({ timeout }));
|
|
174
|
+
}
|
|
175
|
+
/** Deprecated in Playwright in favour of `pressSequentially` or `fill`. */
|
|
176
|
+
async type(text, options = {}) {
|
|
177
|
+
return this.run('type', options, (timeout) => this.rawLocator.type(text, { delay: options.delay ?? 0, timeout }));
|
|
178
|
+
}
|
|
179
|
+
/** Types text key by key (fires keydown/keypress/keyup per character). */
|
|
180
|
+
async pressSequentially(text, options = {}) {
|
|
181
|
+
return this.run('pressSequentially', options, (timeout) => this.rawLocator.pressSequentially(text, { delay: options.delay ?? 0, timeout }));
|
|
182
|
+
}
|
|
183
|
+
async press(key, options = {}) {
|
|
184
|
+
return this.run('press', options, (timeout) => this.rawLocator.press(key, { timeout }), key);
|
|
185
|
+
}
|
|
186
|
+
async check(options = {}) {
|
|
187
|
+
return this.run('check', options, (timeout) => this.rawLocator.check({ timeout }));
|
|
188
|
+
}
|
|
189
|
+
async uncheck(options = {}) {
|
|
190
|
+
return this.run('uncheck', options, (timeout) => this.rawLocator.uncheck({ timeout }));
|
|
191
|
+
}
|
|
192
|
+
async setChecked(checked, options = {}) {
|
|
193
|
+
return this.run('setChecked', options, (timeout) => this.rawLocator.setChecked(checked, { timeout }));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Selects options by value or label (strings), or by `{ value }`, `{ label }`, `{ index }`.
|
|
197
|
+
* Returns the selected values.
|
|
198
|
+
*/
|
|
199
|
+
async selectOption(values, options = {}) {
|
|
200
|
+
const list = (Array.isArray(values) ? values : [values]).map((v) => (typeof v === 'string' ? { value: v } : v));
|
|
201
|
+
return this.run('selectOption', options, async (timeout) => {
|
|
202
|
+
try {
|
|
203
|
+
return await this.rawLocator.selectOption(list, { timeout: Math.min(timeout, 2000) });
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
// Playwright matches a plain string against value *or* label; mirror that.
|
|
207
|
+
if (!list.every((v) => 'value' in v && Object.keys(v).length === 1))
|
|
208
|
+
throw error;
|
|
209
|
+
return this.rawLocator.selectOption(list.map((v) => ({ label: v.value })), { timeout });
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async selectText(options = {}) {
|
|
214
|
+
return this.run('selectText', options, (timeout) => this.rawLocator.selectText({ timeout }));
|
|
215
|
+
}
|
|
216
|
+
/** Sets the files of an `<input type=file>`. Paths must be inside `security.uploads.allowedDirs`. */
|
|
217
|
+
async setInputFiles(files, options = {}) {
|
|
218
|
+
let list;
|
|
219
|
+
try {
|
|
220
|
+
list = this.host.validateUploads(Array.isArray(files) ? files : [files]);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
return Promise.reject(error);
|
|
224
|
+
}
|
|
225
|
+
return this.run('setInputFiles', options, (timeout) => this.rawLocator.setInputFiles(list, { timeout }));
|
|
226
|
+
}
|
|
227
|
+
/** Drags this element onto `target` (mouse down, move, up). */
|
|
228
|
+
async dragTo(target, options = {}) {
|
|
229
|
+
const t = unwrapLocator(target);
|
|
230
|
+
return this.run('dragTo', options, (timeout) => this.rawLocator.dragTo(t, { timeout }));
|
|
231
|
+
}
|
|
232
|
+
async dispatchEvent(type, eventInit = {}, options = {}) {
|
|
233
|
+
if (typeof type !== 'string' || !type)
|
|
234
|
+
return Promise.reject(new ValidationError('Event type must be a non-empty string'));
|
|
235
|
+
return this.run('dispatchEvent', options, (timeout) => this.rawLocator.dispatchEvent(type, eventInit, { timeout }));
|
|
236
|
+
}
|
|
237
|
+
async drop(payload, options = {}) {
|
|
238
|
+
let files;
|
|
239
|
+
try {
|
|
240
|
+
files = payload.files ? this.host.validateUploads(payload.files) : undefined;
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
return Promise.reject(error);
|
|
244
|
+
}
|
|
245
|
+
return this.run('drop', options, (timeout) => this.rawLocator.drop({ ...payload, ...(files ? { files } : {}) }, { timeout }));
|
|
246
|
+
}
|
|
247
|
+
async scrollIntoView(options = {}) {
|
|
248
|
+
return this.run('scrollIntoView', options, (timeout) => this.rawLocator.scrollIntoView({ timeout }));
|
|
249
|
+
}
|
|
250
|
+
/** Playwright name for `scrollIntoView`. */
|
|
251
|
+
async scrollIntoViewIfNeeded(options = {}) {
|
|
252
|
+
return this.scrollIntoView(options);
|
|
253
|
+
}
|
|
254
|
+
async highlight() {
|
|
255
|
+
return this.rawLocator.highlight();
|
|
256
|
+
}
|
|
257
|
+
// ---- queries ------------------------------------------------------------------------------
|
|
258
|
+
async count() {
|
|
259
|
+
return this.rawLocator.count();
|
|
260
|
+
}
|
|
261
|
+
/** Waits for the element to reach a state (default `visible`). */
|
|
262
|
+
async waitFor(options = {}) {
|
|
263
|
+
return this.run('waitFor', options, (timeout) => this.rawLocator.waitFor({ state: options.state ?? 'visible', timeout }));
|
|
264
|
+
}
|
|
265
|
+
async textContent(options = {}) {
|
|
266
|
+
return this.run('textContent', options, (timeout) => this.rawLocator.textContent({ timeout }));
|
|
267
|
+
}
|
|
268
|
+
async innerText(options = {}) {
|
|
269
|
+
return this.run('innerText', options, (timeout) => this.rawLocator.innerText({ timeout }));
|
|
270
|
+
}
|
|
271
|
+
async innerHTML(options = {}) {
|
|
272
|
+
return this.run('innerHTML', options, (timeout) => this.rawLocator.innerHTML({ timeout }));
|
|
273
|
+
}
|
|
274
|
+
async inputValue(options = {}) {
|
|
275
|
+
return this.run('inputValue', options, (timeout) => this.rawLocator.inputValue({ timeout }));
|
|
276
|
+
}
|
|
277
|
+
async getAttribute(name, options = {}) {
|
|
278
|
+
return this.run('getAttribute', options, (timeout) => this.rawLocator.getAttribute(name, { timeout }));
|
|
279
|
+
}
|
|
280
|
+
async allTextContents() {
|
|
281
|
+
return this.rawLocator.allTextContents();
|
|
282
|
+
}
|
|
283
|
+
async allInnerTexts() {
|
|
284
|
+
return this.rawLocator.allInnerTexts();
|
|
285
|
+
}
|
|
286
|
+
async boundingBox(options = {}) {
|
|
287
|
+
return this.run('boundingBox', options, (timeout) => this.rawLocator.boundingBox({ timeout }));
|
|
288
|
+
}
|
|
289
|
+
async screenshot(options = {}) {
|
|
290
|
+
const opts = options.mask ? { ...options, mask: options.mask.map((m) => unwrapLocator(m)) } : options;
|
|
291
|
+
return this.run('screenshot', options, (timeout) => this.rawLocator.screenshot({ ...opts, timeout }));
|
|
292
|
+
}
|
|
293
|
+
async ariaSnapshot(options = {}) {
|
|
294
|
+
return this.run('ariaSnapshot', options, (timeout) => this.rawLocator.ariaSnapshot({ timeout }));
|
|
295
|
+
}
|
|
296
|
+
/** Element state snapshot without waiting (first match). */
|
|
297
|
+
async state() {
|
|
298
|
+
return this.rawLocator.state();
|
|
299
|
+
}
|
|
300
|
+
/** Does not wait; false when nothing matches. Throws `AmbiguousElementError` when several match. */
|
|
301
|
+
async isVisible() {
|
|
302
|
+
return this.is('visible');
|
|
303
|
+
}
|
|
304
|
+
async isHidden() {
|
|
305
|
+
return this.is('hidden');
|
|
306
|
+
}
|
|
307
|
+
async isEnabled(options = {}) {
|
|
308
|
+
return this.is('enabled', options);
|
|
309
|
+
}
|
|
310
|
+
async isDisabled(options = {}) {
|
|
311
|
+
return this.is('disabled', options);
|
|
312
|
+
}
|
|
313
|
+
async isEditable(options = {}) {
|
|
314
|
+
return this.is('editable', options);
|
|
315
|
+
}
|
|
316
|
+
async isChecked(options = {}) {
|
|
317
|
+
return this.is('checked', options);
|
|
318
|
+
}
|
|
319
|
+
async is(state, options = {}) {
|
|
320
|
+
return this.run(`is${state[0].toUpperCase()}${state.slice(1)}`, options, (timeout) => this.rawLocator.is(state, { timeout }));
|
|
321
|
+
}
|
|
322
|
+
/** Runs `fn` with the matched element in the page (local only: executes code). */
|
|
323
|
+
async evaluate(fn, arg) {
|
|
324
|
+
this.host.assertCodeExecution?.('locator.evaluate');
|
|
325
|
+
return this.rawLocator.evaluate(fn, arg);
|
|
326
|
+
}
|
|
327
|
+
/** Runs `fn` with all matched elements (local only). */
|
|
328
|
+
async evaluateAll(fn, arg) {
|
|
329
|
+
this.host.assertCodeExecution?.('locator.evaluateAll');
|
|
330
|
+
return this.rawLocator.evaluateAll(fn, arg);
|
|
331
|
+
}
|
|
332
|
+
toString() {
|
|
333
|
+
return `BashirLocator(${this.selector})`;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/** Locates elements inside an iframe (Playwright's `FrameLocator`). */
|
|
337
|
+
export class BashirFrameLocator {
|
|
338
|
+
scope;
|
|
339
|
+
frameSelector;
|
|
340
|
+
host;
|
|
341
|
+
constructor(scope,
|
|
342
|
+
/** Selector of the `<iframe>` element(s). */
|
|
343
|
+
frameSelector, host) {
|
|
344
|
+
this.scope = scope;
|
|
345
|
+
this.frameSelector = frameSelector;
|
|
346
|
+
this.host = host;
|
|
347
|
+
if (typeof frameSelector !== 'string' || !frameSelector.trim())
|
|
348
|
+
throw new ValidationError('Frame selector must be a non-empty string');
|
|
349
|
+
}
|
|
350
|
+
locator(selectorOrLocator, options = {}) {
|
|
351
|
+
const inner = typeof selectorOrLocator === 'string' ? selectorOrLocator : selectorOrLocator.selector;
|
|
352
|
+
const loc = new BashirLocator(this.scope, `${this.frameSelector} >> ${ENTER_FRAME} >> ${inner}`, this.host);
|
|
353
|
+
return Object.keys(options).length ? loc.filter(options) : loc;
|
|
354
|
+
}
|
|
355
|
+
getByRole(role, options = {}) {
|
|
356
|
+
return this.locator(by.role(role, options));
|
|
357
|
+
}
|
|
358
|
+
getByText(text, options = {}) {
|
|
359
|
+
return this.locator(by.text(text, options));
|
|
360
|
+
}
|
|
361
|
+
getByLabel(text, options = {}) {
|
|
362
|
+
return this.locator(by.label(text, options));
|
|
363
|
+
}
|
|
364
|
+
getByPlaceholder(text, options = {}) {
|
|
365
|
+
return this.locator(by.placeholder(text, options));
|
|
366
|
+
}
|
|
367
|
+
getByAltText(text, options = {}) {
|
|
368
|
+
return this.locator(by.altText(text, options));
|
|
369
|
+
}
|
|
370
|
+
getByTitle(text, options = {}) {
|
|
371
|
+
return this.locator(by.title(text, options));
|
|
372
|
+
}
|
|
373
|
+
getByTestId(id) {
|
|
374
|
+
return this.locator(testIdSelector(id, this.host.testIdAttribute()));
|
|
375
|
+
}
|
|
376
|
+
frameLocator(selector) {
|
|
377
|
+
return new BashirFrameLocator(this.scope, `${this.frameSelector} >> ${ENTER_FRAME} >> ${selector}`, this.host);
|
|
378
|
+
}
|
|
379
|
+
first() {
|
|
380
|
+
return new BashirFrameLocator(this.scope, by.first(this.frameSelector), this.host);
|
|
381
|
+
}
|
|
382
|
+
last() {
|
|
383
|
+
return new BashirFrameLocator(this.scope, by.last(this.frameSelector), this.host);
|
|
384
|
+
}
|
|
385
|
+
nth(index) {
|
|
386
|
+
return new BashirFrameLocator(this.scope, by.nth(this.frameSelector, index), this.host);
|
|
387
|
+
}
|
|
388
|
+
/** Locator for the `<iframe>` element itself. */
|
|
389
|
+
owner() {
|
|
390
|
+
return new BashirLocator(this.scope, this.frameSelector, this.host);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
/** `getByTestId` selector honouring the configured attribute; a RegExp matches the attribute value. */
|
|
394
|
+
export function testIdSelector(id, attribute) {
|
|
395
|
+
try {
|
|
396
|
+
return by.testId(id, attribute);
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
throw new ValidationError(error.message);
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AG,IAAI,CAAC,aAAa,OAAO,WAAW,OAAO,QAAQ,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACjH,CAAC;IACD,KAAK;QACH,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACrF,CAAC;IACD,IAAI;QACF,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpF,CAAC;IACD,GAAG,CAAC,KAAa;QACf,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1F,CAAC;IACD,iDAAiD;IACjD,KAAK;QACH,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACtE,CAAC;CACF;AAED,uGAAuG;AACvG,MAAM,UAAU,cAAc,CAAC,EAAmB,EAAE,SAAiB;IACnE,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,eAAe,CAAE,KAAe,CAAC,OAAO,CAAC,CAAC;IACtD,CAAC;AACH,CAAC"}
|
package/dist/login.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { BashirPage } from './page.js';
|
|
2
|
+
/**
|
|
3
|
+
* Kinds of CAPTCHA challenges BashirWeb can detect during a login flow.
|
|
4
|
+
*
|
|
5
|
+
* Detection is intentionally limited to recognising well-known challenge widgets so
|
|
6
|
+
* BashirWeb can hand the challenge to the authorised user. BashirWeb never solves a
|
|
7
|
+
* CAPTCHA automatically — that would be CAPTCHA bypass, which this project refuses to do.
|
|
8
|
+
*/
|
|
9
|
+
export type CaptchaKind = 'recaptcha' | 'hcaptcha' | 'turnstile' | 'image' | 'unknown';
|
|
10
|
+
/** A CAPTCHA challenge detected on the page, passed to the `onCaptcha` handoff. */
|
|
11
|
+
export interface CaptchaChallenge {
|
|
12
|
+
kind: CaptchaKind;
|
|
13
|
+
/** A selector that locates the challenge widget on the page. */
|
|
14
|
+
selector: string;
|
|
15
|
+
/** A human-readable description of the detected challenge. */
|
|
16
|
+
description: string;
|
|
17
|
+
}
|
|
18
|
+
export interface LoginOptions {
|
|
19
|
+
/** The login page URL to navigate to. */
|
|
20
|
+
url: string;
|
|
21
|
+
/** The username / email to submit, authorised by the caller for this account. */
|
|
22
|
+
username: string;
|
|
23
|
+
/** The password to submit, authorised by the caller for this account. Held in memory only. */
|
|
24
|
+
password: string;
|
|
25
|
+
/** CSS selector for the username/email field. Auto-detected when omitted. */
|
|
26
|
+
usernameField?: string;
|
|
27
|
+
/** CSS selector for the password field. Auto-detected when omitted. */
|
|
28
|
+
passwordField?: string;
|
|
29
|
+
/** CSS selector for the submit button/control. Auto-detected (or Enter) when omitted. */
|
|
30
|
+
submit?: string;
|
|
31
|
+
/** How to submit the form. Default `'click'`. */
|
|
32
|
+
submitWith?: 'click' | 'enter';
|
|
33
|
+
/** CSS selector that is present only after a successful login. Auto-detected when omitted. */
|
|
34
|
+
success?: string;
|
|
35
|
+
/** URL (exact or prefix) to wait for after a successful login. */
|
|
36
|
+
successUrl?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Called when a CAPTCHA challenge is detected during the login.
|
|
39
|
+
*
|
|
40
|
+
* This is a **human-in-the-loop handoff**: the authorised user, who is present at the
|
|
41
|
+
* browser and authenticated to the site, solves the challenge themselves, then resolves
|
|
42
|
+
* this callback and the login continues. BashirWeb never solves CAPTCHAs automatically.
|
|
43
|
+
*
|
|
44
|
+
* If a CAPTCHA is detected and no handler is provided, the login fails with a clear
|
|
45
|
+
* error rather than attempting to bypass the challenge.
|
|
46
|
+
*/
|
|
47
|
+
onCaptcha?: (challenge: CaptchaChallenge) => void | Promise<void>;
|
|
48
|
+
/** Overall login timeout in milliseconds. Default 30000. */
|
|
49
|
+
timeout?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface LoginResult {
|
|
52
|
+
/** Whether the login appears to have succeeded. */
|
|
53
|
+
success: boolean;
|
|
54
|
+
/** The final URL after the login attempt. */
|
|
55
|
+
url: string;
|
|
56
|
+
/** Whether navigation moved away from the login URL. */
|
|
57
|
+
leftLoginPage: boolean;
|
|
58
|
+
/** Number of CAPTCHA handoffs that occurred. */
|
|
59
|
+
captchas: number;
|
|
60
|
+
/** How the form was submitted. */
|
|
61
|
+
method: 'form' | 'unknown';
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Logs into a site using credentials the caller has authorised, on a `BashirPage`.
|
|
65
|
+
*
|
|
66
|
+
* Navigates to `options.url`, fills the username/password, submits the form, and waits
|
|
67
|
+
* for the login to complete. If a CAPTCHA challenge is detected, it is handed to the
|
|
68
|
+
* caller's `onCaptcha` callback — the authorised user solves it in the browser — and the
|
|
69
|
+
* login continues. BashirWeb never solves CAPTCHAs automatically.
|
|
70
|
+
*
|
|
71
|
+
* Credentials are held in memory for the duration of the call only; the returned
|
|
72
|
+
* `LoginResult` never contains the password, and the value is not written to BashirWeb's
|
|
73
|
+
* own traces or logs.
|
|
74
|
+
*/
|
|
75
|
+
export declare function loginTo(page: BashirPage, options: LoginOptions): Promise<LoginResult>;
|
|
76
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C;;;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