@applitools/driver
Advanced tools
Comparing version 1.11.31 to 1.11.32
@@ -133,3 +133,3 @@ "use strict"; | ||
} | ||
if (specUtils.isCommonSelector(this._spec, selector)) { | ||
if (specUtils.isObjectCommonSelector(this._spec, selector)) { | ||
if (elements.length > 0) { | ||
@@ -136,0 +136,0 @@ if (selector.child) { |
@@ -51,3 +51,3 @@ "use strict"; | ||
} | ||
if (specUtils.isSimpleCommonSelector(this._selector)) { | ||
if (specUtils.isSimpleCommonSelector(this._selector) && !utils.types.isString(this._selector)) { | ||
this._commonSelector = this._selector; | ||
@@ -54,0 +54,0 @@ } |
@@ -26,19 +26,17 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.withFastCache = exports.splitSelector = exports.transformSelector = exports.isSelector = exports.isCommonSelector = exports.isSimpleCommonSelector = void 0; | ||
exports.withFastCache = exports.splitSelector = exports.transformSelector = exports.isSelector = exports.isObjectCommonSelector = exports.isSimpleCommonSelector = void 0; | ||
const utils = __importStar(require("@applitools/utils")); | ||
function isSimpleCommonSelector(selector) { | ||
return (utils.types.isPlainObject(selector) && | ||
utils.types.has(selector, 'selector') && | ||
utils.types.isString(selector.selector)); | ||
return utils.types.isString(selector) || isObjectCommonSelector(null, selector); | ||
} | ||
exports.isSimpleCommonSelector = isSimpleCommonSelector; | ||
function isCommonSelector(spec, selector) { | ||
function isObjectCommonSelector(spec, selector) { | ||
return (utils.types.isPlainObject(selector) && | ||
utils.types.has(selector, 'selector') && | ||
Object.keys(selector).every(key => ['selector', 'type', 'frame', 'shadow', 'child', 'fallback'].includes(key)) && | ||
(utils.types.isString(selector.selector) || spec.isSelector(selector.selector))); | ||
(utils.types.isString(selector.selector) || !!(spec === null || spec === void 0 ? void 0 : spec.isSelector(selector.selector)))); | ||
} | ||
exports.isCommonSelector = isCommonSelector; | ||
exports.isObjectCommonSelector = isObjectCommonSelector; | ||
function isSelector(spec, selector) { | ||
return spec.isSelector(selector) || utils.types.isString(selector) || isCommonSelector(spec, selector); | ||
return spec.isSelector(selector) || utils.types.isString(selector) || isObjectCommonSelector(spec, selector); | ||
} | ||
@@ -48,3 +46,3 @@ exports.isSelector = isSelector; | ||
var _a, _b; | ||
if ((environment === null || environment === void 0 ? void 0 : environment.isWeb) && isCommonSelector(spec, selector)) { | ||
if ((environment === null || environment === void 0 ? void 0 : environment.isWeb) && isObjectCommonSelector(spec, selector)) { | ||
if (selector.type === 'id') | ||
@@ -59,2 +57,3 @@ selector = { type: 'css', selector: `#${selector.selector}` }; | ||
} | ||
selector; | ||
return (_b = (_a = spec.transformSelector) === null || _a === void 0 ? void 0 : _a.call(spec, selector)) !== null && _b !== void 0 ? _b : selector; | ||
@@ -69,3 +68,3 @@ } | ||
while (targetSelector) { | ||
if (isCommonSelector(spec, targetSelector)) { | ||
if (isObjectCommonSelector(spec, targetSelector)) { | ||
activeSelector.selector = targetSelector.selector; | ||
@@ -72,0 +71,0 @@ if (targetSelector.type) |
{ | ||
"name": "@applitools/driver", | ||
"version": "1.11.31", | ||
"version": "1.11.32", | ||
"description": "Applitools universal framework wrapper", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import type { Location, Size, Region } from '@applitools/utils'; | ||
import { type SpecType, type SpecDriver } from './spec-driver'; | ||
import { type Context } from './context'; | ||
import { type Selector } from './selector'; | ||
import { type Selector, type CommonSelector } from './selector'; | ||
import { type Logger } from '@applitools/logger'; | ||
@@ -40,3 +40,3 @@ export type ElementReference<T extends SpecType> = T['element'] | Selector<T>; | ||
get selector(): Selector<T> | undefined; | ||
get commonSelector(): Selector<never> | null; | ||
get commonSelector(): CommonSelector<never> | null; | ||
get index(): number | undefined; | ||
@@ -43,0 +43,0 @@ get context(): Context<T>; |
import { type SpecType } from './spec-driver'; | ||
export type Selector<T extends SpecType = never> = T['selector'] | string | CommonSelector<T>; | ||
export type CommonSelector<T extends SpecType = never> = { | ||
selector: T['selector'] | string; | ||
export type Selector<T extends SpecType = never> = T['selector'] | CommonSelector<T['selector']>; | ||
export type CommonSelector<TSelector = never> = string | ComplexSelector<TSelector>; | ||
type ComplexSelector<TSelector> = { | ||
selector: TSelector | string; | ||
type?: string; | ||
child?: T['selector'] | string | CommonSelector<T>; | ||
shadow?: T['selector'] | string | CommonSelector<T>; | ||
frame?: T['selector'] | string | CommonSelector<T>; | ||
fallback?: T['selector'] | string | CommonSelector<T>; | ||
child?: TSelector | string | CommonSelector<TSelector>; | ||
shadow?: TSelector | string | CommonSelector<TSelector>; | ||
frame?: TSelector | string | CommonSelector<TSelector>; | ||
fallback?: TSelector | string | CommonSelector<TSelector>; | ||
}; | ||
export {}; |
/// <reference types="node" /> | ||
import type { Location, Size, Region } from '@applitools/utils'; | ||
import type { ScreenOrientation, Cookie } from './types'; | ||
import { type Selector } from './selector'; | ||
import { type CommonSelector } from './selector'; | ||
export type SpecType<TDriver = unknown, TContext = unknown, TElement = unknown, TSelector = unknown> = { | ||
@@ -18,4 +18,4 @@ driver: TDriver; | ||
transformElement?(element: any): T['element']; | ||
transformSelector?(selector: Selector<T>): T['selector']; | ||
untransformSelector?(selector: T['selector'] | Selector<T>): Selector | null; | ||
transformSelector?(selector: CommonSelector<T['selector']> | T['selector']): T['selector']; | ||
untransformSelector?(selector: T['selector']): CommonSelector | null; | ||
extractContext?(element: T['driver'] | T['context']): T['context']; | ||
@@ -22,0 +22,0 @@ extractSelector?(element: T['element']): T['selector']; |
import { type SpecType, type SpecDriver } from './spec-driver'; | ||
import { type Selector, type CommonSelector } from './selector'; | ||
export declare function isSimpleCommonSelector(selector: any): selector is CommonSelector; | ||
export declare function isCommonSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector'>, selector: any): selector is CommonSelector<T>; | ||
export declare function isObjectCommonSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector'> | null, selector: any): selector is Exclude<CommonSelector<T['selector']>, string>; | ||
export declare function isSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector'>, selector: any): selector is Selector<T>; | ||
@@ -6,0 +6,0 @@ export declare function transformSelector<T extends SpecType>(spec: Pick<SpecDriver<T>, 'isSelector' | 'transformSelector'>, selector: Selector<T>, environment?: { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
241377
4000