@dev-blinq/bvt-playwright-js 1.0.0-dev.4.latest.142.1 → 1.0.0-dev.4.latest.149.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/index.d.mts +19 -5
- package/index.mjs +15 -9
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1344,6 +1344,7 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
|
|
|
1344
1344
|
], "type">;
|
|
1345
1345
|
target: z.ZodObject<{
|
|
1346
1346
|
name: z.ZodString;
|
|
1347
|
+
isElementHidden: z.ZodOptional<z.ZodBoolean>;
|
|
1347
1348
|
uniqueSelectors: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
1348
1349
|
z.ZodObject<{
|
|
1349
1350
|
type: z.ZodLiteral<"pw.selectorString">;
|
|
@@ -2112,6 +2113,7 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
|
|
|
2112
2113
|
], "type">;
|
|
2113
2114
|
target: z.ZodObject<{
|
|
2114
2115
|
name: z.ZodString;
|
|
2116
|
+
isElementHidden: z.ZodOptional<z.ZodBoolean>;
|
|
2115
2117
|
uniqueSelectors: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
2116
2118
|
z.ZodObject<{
|
|
2117
2119
|
type: z.ZodLiteral<"pw.selectorString">;
|
|
@@ -2756,6 +2758,7 @@ declare const CommandSchema: z.ZodDiscriminatedUnion<[
|
|
|
2756
2758
|
], "type">;
|
|
2757
2759
|
target: z.ZodObject<{
|
|
2758
2760
|
name: z.ZodString;
|
|
2761
|
+
isElementHidden: z.ZodOptional<z.ZodBoolean>;
|
|
2759
2762
|
uniqueSelectors: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
2760
2763
|
z.ZodObject<{
|
|
2761
2764
|
type: z.ZodLiteral<"pw.selectorString">;
|
|
@@ -4351,6 +4354,7 @@ declare const StepDefinitionSchema: z.ZodObject<{
|
|
|
4351
4354
|
], "type">;
|
|
4352
4355
|
target: z.ZodObject<{
|
|
4353
4356
|
name: z.ZodString;
|
|
4357
|
+
isElementHidden: z.ZodOptional<z.ZodBoolean>;
|
|
4354
4358
|
uniqueSelectors: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
4355
4359
|
z.ZodObject<{
|
|
4356
4360
|
type: z.ZodLiteral<"pw.selectorString">;
|
|
@@ -5119,6 +5123,7 @@ declare const StepDefinitionSchema: z.ZodObject<{
|
|
|
5119
5123
|
], "type">;
|
|
5120
5124
|
target: z.ZodObject<{
|
|
5121
5125
|
name: z.ZodString;
|
|
5126
|
+
isElementHidden: z.ZodOptional<z.ZodBoolean>;
|
|
5122
5127
|
uniqueSelectors: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
5123
5128
|
z.ZodObject<{
|
|
5124
5129
|
type: z.ZodLiteral<"pw.selectorString">;
|
|
@@ -5763,6 +5768,7 @@ declare const StepDefinitionSchema: z.ZodObject<{
|
|
|
5763
5768
|
], "type">;
|
|
5764
5769
|
target: z.ZodObject<{
|
|
5765
5770
|
name: z.ZodString;
|
|
5771
|
+
isElementHidden: z.ZodOptional<z.ZodBoolean>;
|
|
5766
5772
|
uniqueSelectors: z.ZodArray<z.ZodDiscriminatedUnion<[
|
|
5767
5773
|
z.ZodObject<{
|
|
5768
5774
|
type: z.ZodLiteral<"pw.selectorString">;
|
|
@@ -8817,6 +8823,9 @@ type PWSelectorDetails = {
|
|
|
8817
8823
|
score: number;
|
|
8818
8824
|
elements?: Element[];
|
|
8819
8825
|
};
|
|
8826
|
+
type SelectorGenerationOptions = Partial<InternalOptions> & {
|
|
8827
|
+
visibleOnly?: boolean;
|
|
8828
|
+
};
|
|
8820
8829
|
declare class SelectorGenerator {
|
|
8821
8830
|
private injectedScript;
|
|
8822
8831
|
private _pw;
|
|
@@ -8829,7 +8838,7 @@ declare class SelectorGenerator {
|
|
|
8829
8838
|
private pushCandidate;
|
|
8830
8839
|
getMatchingElements(selector: string, options?: {
|
|
8831
8840
|
visibleOnly?: boolean;
|
|
8832
|
-
root?: Element;
|
|
8841
|
+
root?: Element | Document;
|
|
8833
8842
|
prefix?: string;
|
|
8834
8843
|
}): Element[];
|
|
8835
8844
|
private addNearestTextToSelectors;
|
|
@@ -8837,13 +8846,14 @@ declare class SelectorGenerator {
|
|
|
8837
8846
|
buildPWNoTextCandidates(element: Element, options?: InternalOptions): PWSelectorDetails[];
|
|
8838
8847
|
computeUnique(element: Element, locatorGenerator: (element: Element, options?: InternalOptions & {
|
|
8839
8848
|
isTargetNode: boolean;
|
|
8840
|
-
}) => PWSelectorDetails[], strategy: "text" | "css", options?:
|
|
8849
|
+
}) => PWSelectorDetails[], strategy: "text" | "css", options?: SelectorGenerationOptions): Generator<UniqueSelector>;
|
|
8841
8850
|
computeUnique2(element: Element, locatorGenerator: (element: Element, options?: InternalOptions & {
|
|
8842
8851
|
isTargetNode: boolean;
|
|
8843
|
-
}) => PWSelectorDetails[], strategy: "text" | "css", options?:
|
|
8844
|
-
getUniquePWSelectors(element: Element, options?:
|
|
8852
|
+
}) => PWSelectorDetails[], strategy: "text" | "css", options?: SelectorGenerationOptions): Generator<UniqueSelector>;
|
|
8853
|
+
getUniquePWSelectors(element: Element, options?: SelectorGenerationOptions): Generator<UniqueSelector, undefined, unknown>;
|
|
8845
8854
|
getCSSChainSelector(element: Element, options: {
|
|
8846
8855
|
root?: Element | Document;
|
|
8856
|
+
visibleOnly?: boolean;
|
|
8847
8857
|
}): string;
|
|
8848
8858
|
getUniqueSelectors(element: Element, options?: InternalOptions & {
|
|
8849
8859
|
timeout?: number;
|
|
@@ -8873,6 +8883,7 @@ type ElementActionEvent = {
|
|
|
8873
8883
|
bvtId: string;
|
|
8874
8884
|
details: ElementDetails;
|
|
8875
8885
|
uniqueSelectors: UniqueSelector[];
|
|
8886
|
+
isElementHidden?: boolean;
|
|
8876
8887
|
};
|
|
8877
8888
|
statistics: {
|
|
8878
8889
|
handleEventDurationMs: string;
|
|
@@ -9123,6 +9134,9 @@ type UnboxedTuple<T extends unknown[]> = {
|
|
|
9123
9134
|
[K in keyof T]: Unboxed<T[K]>;
|
|
9124
9135
|
};
|
|
9125
9136
|
type LocatorScope = Frame | FrameLocator;
|
|
9137
|
+
type LocatorVisibilityOptions = {
|
|
9138
|
+
isElementHidden?: boolean;
|
|
9139
|
+
};
|
|
9126
9140
|
type GlobalThis = {
|
|
9127
9141
|
__bvt: {
|
|
9128
9142
|
BrowserObserver: typeof BrowserObserver;
|
|
@@ -9373,7 +9387,7 @@ declare class Tester {
|
|
|
9373
9387
|
isFrameObject(frameScope: LocatorScope): frameScope is Frame;
|
|
9374
9388
|
getFrameObjectFromFrameScope(frameScope: FrameLocator | Frame): Promise<Frame>;
|
|
9375
9389
|
getFrame(scope: Page, frameElementDescriptors: ElementCommand["target"]["frames"]): Promise<LocatorScope>;
|
|
9376
|
-
getLocator(scope: LocatorScope, uniqueSelector: UniqueSelector): {
|
|
9390
|
+
getLocator(scope: LocatorScope, uniqueSelector: UniqueSelector, options?: LocatorVisibilityOptions): {
|
|
9377
9391
|
target: Locator;
|
|
9378
9392
|
};
|
|
9379
9393
|
executeElementAction(locator: Locator, action: ElementAction): Promise<void>;
|
package/index.mjs
CHANGED
|
@@ -6562,6 +6562,7 @@ const RichElementTargetDetailsSchema = object({
|
|
|
6562
6562
|
}).passthrough();
|
|
6563
6563
|
const elementTargetSchema = object({
|
|
6564
6564
|
name: string(),
|
|
6565
|
+
isElementHidden: boolean().optional(),
|
|
6565
6566
|
uniqueSelectors: array(UniqueSelectorSchema),
|
|
6566
6567
|
frames: array(object({
|
|
6567
6568
|
name: string(),
|
|
@@ -27288,7 +27289,7 @@ var Tester = class {
|
|
|
27288
27289
|
if (!frameElementDescriptors || frameElementDescriptors.length === 0) return scope.mainFrame();
|
|
27289
27290
|
let currentFrame = scope.mainFrame();
|
|
27290
27291
|
for (const frameDescriptor of frameElementDescriptors) for (const selectorInfo of frameDescriptor.uniqueSelectors) {
|
|
27291
|
-
const { target } = this.getLocator(currentFrame, selectorInfo);
|
|
27292
|
+
const { target } = this.getLocator(currentFrame, selectorInfo, { isElementHidden: false });
|
|
27292
27293
|
try {
|
|
27293
27294
|
if (!await target.elementHandle()) throw new Error(`Could not find element for frame selector: ${JSON.stringify(selectorInfo)}`);
|
|
27294
27295
|
const selector = target._selector;
|
|
@@ -27300,9 +27301,14 @@ var Tester = class {
|
|
|
27300
27301
|
}
|
|
27301
27302
|
return currentFrame;
|
|
27302
27303
|
}
|
|
27303
|
-
getLocator(scope, uniqueSelector) {
|
|
27304
|
+
getLocator(scope, uniqueSelector, options) {
|
|
27304
27305
|
switch (uniqueSelector.type) {
|
|
27305
|
-
case "pw.selectorString":
|
|
27306
|
+
case "pw.selectorString": {
|
|
27307
|
+
const visibleSuffix = options?.isElementHidden === true ? "" : ` >> visible=true`;
|
|
27308
|
+
const finalSelector = uniqueSelector.selectorString + visibleSuffix;
|
|
27309
|
+
this.obs.logger.info(`getLocator(pw.selectorString): isElementHidden=${options?.isElementHidden}, visibleAppended=${visibleSuffix !== ""}, finalSelector=${finalSelector}`);
|
|
27310
|
+
return { target: scope.locator(finalSelector) };
|
|
27311
|
+
}
|
|
27306
27312
|
case "bvt.selectorObject": throw new Error(`Selector type "bvt.selectorObject" is not yet supported in getLocator`);
|
|
27307
27313
|
default:
|
|
27308
27314
|
const _exhaustiveCheck = uniqueSelector;
|
|
@@ -27683,7 +27689,7 @@ var Tester = class {
|
|
|
27683
27689
|
const selectorInfo = target.uniqueSelectors[chosenSelectorIndex];
|
|
27684
27690
|
if (!selectorInfo) throw new Error(`No selector found for target "${target.name}" at chosenSelectorIndex ${chosenSelectorIndex}. Available selectors: ${JSON.stringify(target.uniqueSelectors)}`);
|
|
27685
27691
|
const frame = await this.getFrame(input.page, target.frames);
|
|
27686
|
-
const locator = this.getLocator(frame, selectorInfo);
|
|
27692
|
+
const locator = this.getLocator(frame, selectorInfo, target);
|
|
27687
27693
|
try {
|
|
27688
27694
|
const dataWithDefaultTimeout = {
|
|
27689
27695
|
...data,
|
|
@@ -27704,7 +27710,7 @@ var Tester = class {
|
|
|
27704
27710
|
for (let i = 0; i < target.uniqueSelectors.length; i++) {
|
|
27705
27711
|
if (i === chosenSelectorIndex) continue;
|
|
27706
27712
|
const selectorInfo = target.uniqueSelectors[i];
|
|
27707
|
-
const locator = this.getLocator(frame, selectorInfo);
|
|
27713
|
+
const locator = this.getLocator(frame, selectorInfo, target);
|
|
27708
27714
|
try {
|
|
27709
27715
|
this.obs.logger.info(`Retrying action "${data.type}" using next selector: ${JSON.stringify(selectorInfo)}`);
|
|
27710
27716
|
const dataWithModifiedTimeout = {
|
|
@@ -27735,7 +27741,7 @@ var Tester = class {
|
|
|
27735
27741
|
const chosenSelectorIndex = target.chosenSelectorIndex ?? 0;
|
|
27736
27742
|
const selectorInfo = target.uniqueSelectors[chosenSelectorIndex];
|
|
27737
27743
|
const frame = await this.getFrame(input.page, target.frames);
|
|
27738
|
-
const locator = this.getLocator(frame, selectorInfo);
|
|
27744
|
+
const locator = this.getLocator(frame, selectorInfo, target);
|
|
27739
27745
|
try {
|
|
27740
27746
|
this.obs.logger.info(`Executing assertion "${data.type}" using selector: ${JSON.stringify(selectorInfo)}`);
|
|
27741
27747
|
const dataWithDefaultTimeout = {
|
|
@@ -27755,7 +27761,7 @@ var Tester = class {
|
|
|
27755
27761
|
for (let i = 0; i < target.uniqueSelectors.length; i++) {
|
|
27756
27762
|
if (i === chosenSelectorIndex) continue;
|
|
27757
27763
|
const selectorInfo = target.uniqueSelectors[i];
|
|
27758
|
-
const locator = this.getLocator(frame, selectorInfo);
|
|
27764
|
+
const locator = this.getLocator(frame, selectorInfo, target);
|
|
27759
27765
|
const dataWithModifiedTimeout = {
|
|
27760
27766
|
...data,
|
|
27761
27767
|
options: {
|
|
@@ -27788,7 +27794,7 @@ var Tester = class {
|
|
|
27788
27794
|
const selectorInfo = target.uniqueSelectors[chosenSelectorIndex];
|
|
27789
27795
|
if (!selectorInfo) throw new Error(`No selector found for target "${target.name}" at chosenSelectorIndex ${chosenSelectorIndex}. Available selectors: ${JSON.stringify(target.uniqueSelectors)}`);
|
|
27790
27796
|
const frame = await this.getFrame(input.page, target.frames);
|
|
27791
|
-
const locator = this.getLocator(frame, selectorInfo);
|
|
27797
|
+
const locator = this.getLocator(frame, selectorInfo, target);
|
|
27792
27798
|
try {
|
|
27793
27799
|
this.obs.logger.info(`Executing extraction "${extract.type}" using selector: ${JSON.stringify(selectorInfo)}`);
|
|
27794
27800
|
await this.executeElementExtraction(locator.target, extract, storageDetails);
|
|
@@ -27801,7 +27807,7 @@ var Tester = class {
|
|
|
27801
27807
|
for (let i = 0; i < target.uniqueSelectors.length; i++) {
|
|
27802
27808
|
if (i === chosenSelectorIndex) continue;
|
|
27803
27809
|
const fallbackSelectorInfo = target.uniqueSelectors[i];
|
|
27804
|
-
const fallbackLocator = this.getLocator(frame, fallbackSelectorInfo);
|
|
27810
|
+
const fallbackLocator = this.getLocator(frame, fallbackSelectorInfo, target);
|
|
27805
27811
|
try {
|
|
27806
27812
|
this.obs.logger.info(`Retrying extraction "${extract.type}" using next selector: ${JSON.stringify(fallbackSelectorInfo)}`);
|
|
27807
27813
|
await this.executeElementExtraction(fallbackLocator.target, extract, storageDetails);
|