New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/driver

Package Overview
Dependencies
Maintainers
30
Versions
220
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/driver - npm Package Compare versions

Comparing version 1.9.7 to 1.9.8

6

dist/capabilities.js

@@ -5,3 +5,3 @@ "use strict";

function parseCapabilities(capabilities, customConfig) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
if (capabilities.capabilities)

@@ -39,5 +39,5 @@ capabilities = capabilities.capabilities;

info.pixelRatio = capabilities.pixelRatio;
info.statusBarHeight = capabilities.statBarHeight;
info.statusBarSize = (_o = capabilities.statBarHeight) !== null && _o !== void 0 ? _o : (_p = capabilities.viewportRect) === null || _p === void 0 ? void 0 : _p.top;
if (info.displaySize && info.orientation && capabilities.viewportRect) {
info.navigationBarHeight =
info.navigationBarSize =
info.orientation === 'landscape'

@@ -44,0 +44,0 @@ ? info.displaySize.width - (capabilities.viewportRect.left + capabilities.viewportRect.width)

@@ -235,3 +235,3 @@ "use strict";

context,
shadow: root ? new element_1.Element({ spec: this._spec, context, element, logger: this._logger, root }) : null,
shadow: element && new element_1.Element({ spec: this._spec, context, element, logger: this._logger }),
selector: currentSelector,

@@ -241,3 +241,2 @@ };

async element(elementOrSelector) {
var _a;
if (this._spec.isElement(elementOrSelector)) {

@@ -254,3 +253,3 @@ return new element_1.Element({ spec: this._spec, context: this, element: elementOrSelector, logger: this._logger });

return null;
const element = await this._spec.findElement(root.context.target, specUtils.transformSelector(this._spec, root.selector, this.driver), (_a = root.shadow) === null || _a === void 0 ? void 0 : _a.target);
const element = await this._spec.findElement(root.context.target, specUtils.transformSelector(this._spec, root.selector, this.driver), root.shadow && (await root.shadow.getShadowRoot()));
// TODO root.selector is not a full selector from context root to an element, but selector inside a shadow

@@ -266,3 +265,2 @@ return element

async elements(elementOrSelector) {
var _a;
if (this._spec.isElement(elementOrSelector)) {

@@ -279,3 +277,3 @@ return [new element_1.Element({ spec: this._spec, context: this, element: elementOrSelector, logger: this._logger })];

return [];
const elements = await this._spec.findElements(root.context.target, specUtils.transformSelector(this._spec, root.selector, this.driver), (_a = root.shadow) === null || _a === void 0 ? void 0 : _a.target);
const elements = await this._spec.findElements(root.context.target, specUtils.transformSelector(this._spec, root.selector, this.driver), root.shadow && (await root.shadow.getShadowRoot()));
return elements.map((element, index) => {

@@ -282,0 +280,0 @@ // TODO root.selector is not a full selector from context root to an element, but selector inside a shadow

@@ -110,9 +110,9 @@ "use strict";

}
get statusBarHeight() {
get statusBarSize() {
var _a;
return (_a = this._driverInfo.statusBarHeight) !== null && _a !== void 0 ? _a : (this.isNative ? 0 : undefined);
return (_a = this._driverInfo.statusBarSize) !== null && _a !== void 0 ? _a : (this.isNative ? 0 : undefined);
}
get navigationBarHeight() {
get navigationBarSize() {
var _a;
return (_a = this._driverInfo.navigationBarHeight) !== null && _a !== void 0 ? _a : (this.isNative ? 0 : undefined);
return (_a = this._driverInfo.navigationBarSize) !== null && _a !== void 0 ? _a : (this.isNative ? 0 : undefined);
}

@@ -148,4 +148,4 @@ get isNative() {

async init() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
var _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
var _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
const capabilities = await ((_b = (_a = this._spec).getCapabilities) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));

@@ -156,21 +156,25 @@ this._logger.log('Driver capabilities', capabilities);

this._driverInfo = { ...capabilitiesInfo, ...driverInfo };
if (this.isMobile) {
this._driverInfo.orientation =
(_e = (await this.getOrientation().catch(() => undefined))) !== null && _e !== void 0 ? _e : this._driverInfo.orientation;
}
if (this.isWeb) {
(_e = (_x = this._driverInfo).pixelRatio) !== null && _e !== void 0 ? _e : (_x.pixelRatio = await this.execute(snippets.getPixelRatio));
(_f = (_y = this._driverInfo).viewportScale) !== null && _f !== void 0 ? _f : (_y.viewportScale = await this.execute(snippets.getViewportScale));
(_g = (_z = this._driverInfo).userAgent) !== null && _g !== void 0 ? _g : (_z.userAgent = await this.execute(snippets.getUserAgent));
(_f = (_y = this._driverInfo).pixelRatio) !== null && _f !== void 0 ? _f : (_y.pixelRatio = await this.execute(snippets.getPixelRatio));
(_g = (_z = this._driverInfo).viewportScale) !== null && _g !== void 0 ? _g : (_z.viewportScale = await this.execute(snippets.getViewportScale));
(_h = (_0 = this._driverInfo).userAgent) !== null && _h !== void 0 ? _h : (_0.userAgent = await this.execute(snippets.getUserAgent));
if (this._driverInfo.userAgent) {
const userAgentInfo = (0, user_agent_1.parseUserAgent)(this._driverInfo.userAgent);
this._driverInfo.browserName = (_h = userAgentInfo.browserName) !== null && _h !== void 0 ? _h : this._driverInfo.browserName;
this._driverInfo.browserVersion = (_j = userAgentInfo.browserVersion) !== null && _j !== void 0 ? _j : this._driverInfo.browserVersion;
this._driverInfo.browserName = (_j = userAgentInfo.browserName) !== null && _j !== void 0 ? _j : this._driverInfo.browserName;
this._driverInfo.browserVersion = (_k = userAgentInfo.browserVersion) !== null && _k !== void 0 ? _k : this._driverInfo.browserVersion;
if (this._driverInfo.isMobile) {
(_k = (_0 = this._driverInfo).platformName) !== null && _k !== void 0 ? _k : (_0.platformName = userAgentInfo.platformName);
(_l = (_1 = this._driverInfo).platformVersion) !== null && _l !== void 0 ? _l : (_1.platformVersion = userAgentInfo.platformVersion);
(_l = (_1 = this._driverInfo).platformName) !== null && _l !== void 0 ? _l : (_1.platformName = userAgentInfo.platformName);
(_m = (_2 = this._driverInfo).platformVersion) !== null && _m !== void 0 ? _m : (_2.platformVersion = userAgentInfo.platformVersion);
}
else {
this._driverInfo.platformName = (_m = userAgentInfo.platformName) !== null && _m !== void 0 ? _m : this._driverInfo.platformName;
this._driverInfo.platformVersion = (_o = userAgentInfo.platformVersion) !== null && _o !== void 0 ? _o : this._driverInfo.platformVersion;
this._driverInfo.platformName = (_o = userAgentInfo.platformName) !== null && _o !== void 0 ? _o : this._driverInfo.platformName;
this._driverInfo.platformVersion = (_p = userAgentInfo.platformVersion) !== null && _p !== void 0 ? _p : this._driverInfo.platformVersion;
}
}
(_p = (_2 = this._driverInfo).features) !== null && _p !== void 0 ? _p : (_2.features = {});
(_q = (_3 = this._driverInfo.features).allCookies) !== null && _q !== void 0 ? _q : (_3.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
(_q = (_3 = this._driverInfo).features) !== null && _q !== void 0 ? _q : (_3.features = {});
(_r = (_4 = this._driverInfo.features).allCookies) !== null && _r !== void 0 ? _r : (_4.allCookies = /chrome/i.test(this._driverInfo.browserName) && !this._driverInfo.isMobile);
}

@@ -180,37 +184,49 @@ else {

let windowSize = await this._spec.getWindowSize(this.target);
(_r = (_4 = this._driverInfo).displaySize) !== null && _r !== void 0 ? _r : (_4.displaySize = windowSize);
const orientation = await this.getOrientation();
(_s = (_5 = this._driverInfo).displaySize) !== null && _s !== void 0 ? _s : (_5.displaySize = windowSize);
if (this.isAndroid) {
// bar sizes could be extracted only on android
const barsSize = await ((_t = (_s = this._spec).getBarsSize) === null || _t === void 0 ? void 0 : _t.call(_s, this.target).catch(() => undefined));
if (barsSize) {
this._logger.log('Driver bars size', barsSize);
// navigation bar height is replaced with the width in landscape orientation on android (due to the bug in appium)
if (orientation === 'landscape')
barsSize.navigationBarHeight = barsSize.navigationBarWidth;
const systemBars = await ((_u = (_t = this._spec).getSystemBars) === null || _u === void 0 ? void 0 : _u.call(_t, this.target).catch(() => null));
const { statusBar, navigationBar } = systemBars !== null && systemBars !== void 0 ? systemBars : {};
if (statusBar === null || statusBar === void 0 ? void 0 : statusBar.visible) {
this._logger.log('Driver status bar', statusBar);
const statusBarSize = statusBar.height;
// when status bar is overlapping content on android it returns status bar height equal to display height
if (barsSize.statusBarHeight < this._driverInfo.displaySize.height) {
this._driverInfo.statusBarHeight = Math.max((_u = this._driverInfo.statusBarHeight) !== null && _u !== void 0 ? _u : 0, barsSize.statusBarHeight);
if (statusBarSize < this._driverInfo.displaySize.height) {
this._driverInfo.statusBarSize = Math.max((_v = this._driverInfo.statusBarSize) !== null && _v !== void 0 ? _v : 0, statusBarSize);
}
// when navigation bar is invisible on android it returns navigation bar height equal to display height
if (barsSize.navigationBarHeight < this._driverInfo.displaySize.height) {
this._driverInfo.navigationBarHeight = Math.max((_v = this._driverInfo.navigationBarHeight) !== null && _v !== void 0 ? _v : 0, barsSize.navigationBarHeight);
}
if (navigationBar === null || navigationBar === void 0 ? void 0 : navigationBar.visible) {
this._logger.log('Driver navigation size', navigationBar);
// if navigation bar is placed on the right side is screen the the orientation is landscape-secondary
if (navigationBar.x > 0)
this._driverInfo.orientation = 'landscape-secondary';
// navigation bar size could be its height or width depending on screen orientation
const navigationBarSize = navigationBar[this.orientation.startsWith('landscape') ? 'width' : 'height'];
// when navigation bar is invisible on android it returns navigation bar size equal to display size
if (navigationBarSize <
this._driverInfo.displaySize[this.orientation.startsWith('landscape') ? 'width' : 'height']) {
this._driverInfo.navigationBarSize = Math.max((_w = this._driverInfo.navigationBarSize) !== null && _w !== void 0 ? _w : 0, navigationBarSize);
}
else {
this._driverInfo.navigationBarHeight = 0;
this._driverInfo.navigationBarSize = 0;
}
// bar heights have to be scaled on android
(_5 = this._driverInfo).statusBarHeight && (_5.statusBarHeight = this._driverInfo.statusBarHeight / this.pixelRatio);
(_6 = this._driverInfo).navigationBarHeight && (_6.navigationBarHeight = this._driverInfo.navigationBarHeight / this.pixelRatio);
}
windowSize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio);
(_7 = this._driverInfo).displaySize && (_7.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio));
// bar sizes have to be scaled on android
(_6 = this._driverInfo).statusBarSize && (_6.statusBarSize = this._driverInfo.statusBarSize / this.pixelRatio);
(_7 = this._driverInfo).navigationBarSize && (_7.navigationBarSize = this._driverInfo.navigationBarSize / this.pixelRatio);
windowSize = utils.geometry.scale(windowSize, 1 / this.pixelRatio);
(_8 = this._driverInfo).displaySize && (_8.displaySize = utils.geometry.scale(this._driverInfo.displaySize, 1 / this.pixelRatio));
}
// calculate viewport location
(_x = (_9 = this._driverInfo).viewportLocation) !== null && _x !== void 0 ? _x : (_9.viewportLocation = {
x: this.orientation === 'landscape' ? this.navigationBarSize : 0,
y: this.statusBarSize,
});
// calculate viewport size
if (!this._driverInfo.viewportSize) {
if (this.navigationBarHeight > 1) {
if (orientation === 'landscape') {
if (this.navigationBarSize > 1) {
if (this.orientation.startsWith('landscape')) {
this._driverInfo.viewportSize = {
width: this._driverInfo.displaySize.height - this.navigationBarHeight,
height: this._driverInfo.displaySize.width - this.statusBarHeight,
width: this._driverInfo.displaySize.height - this.navigationBarSize,
height: this._driverInfo.displaySize.width - this.statusBarSize,
};

@@ -221,3 +237,3 @@ }

width: this._driverInfo.displaySize.width,
height: this._driverInfo.displaySize.height - this.statusBarHeight - this.navigationBarHeight,
height: this._driverInfo.displaySize.height - this.statusBarSize - this.navigationBarSize,
};

@@ -229,3 +245,3 @@ }

width: windowSize.width,
height: windowSize.height - this.statusBarHeight,
height: windowSize.height - this.statusBarSize,
};

@@ -256,5 +272,2 @@ }

}
if (this.isMobile) {
(_w = (_8 = this._driverInfo).orientation) !== null && _w !== void 0 ? _w : (_8.orientation = await this.getOrientation().catch(() => undefined));
}
this._logger.log('Combined driver info', this._driverInfo);

@@ -426,3 +439,3 @@ return this;

async normalizeRegion(region) {
if (this.isWeb || !utils.types.has(this._driverInfo, ['viewportSize', 'statusBarHeight']))
if (this.isWeb)
return region;

@@ -436,6 +449,3 @@ let normalizedRegion = region;

}
normalizedRegion = utils.geometry.offsetNegative(normalizedRegion, {
x: this.isAndroid && this.orientation === 'landscape' && this.platformVersion > 7 ? this.navigationBarHeight : 0,
y: this.statusBarHeight,
});
normalizedRegion = utils.geometry.offsetNegative(normalizedRegion, this._driverInfo.viewportLocation);
if (normalizedRegion.y < 0) {

@@ -467,2 +477,9 @@ normalizedRegion.height += normalizedRegion.y;

}
async getViewportRegion() {
var _a, _b;
return {
...((_b = (_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.viewportLocation) !== null && _b !== void 0 ? _b : { x: 0, y: 0 }),
...(await this.getViewportSize()),
};
}
async getViewportSize() {

@@ -479,3 +496,3 @@ var _a;

size = await this.getDisplaySize();
size.height -= this.statusBarHeight;
size.height -= this.statusBarSize;
}

@@ -545,3 +562,3 @@ this._logger.log(`Rounding viewport size using`, this._customConfig.useCeilForViewportSize ? 'ceil' : 'round');

let size = await this._spec.getWindowSize(this.target);
if ((await this.getOrientation()) === 'landscape' && size.height > size.width) {
if ((await this.getOrientation()).startsWith('landscape') && size.height > size.width) {
size = { width: size.height, height: size.width };

@@ -556,3 +573,23 @@ }

return;
const orientation = await this._spec.getOrientation(this.target);
let orientation;
if (this.isAndroid) {
this._logger.log('Extracting device orientation using adb command on android');
const rotation = await this.execute('mobile:shell', {
command: "dumpsys window | grep 'mCurrentRotation' | cut -d = -f2",
})
.then(r => { var _a; return (_a = r === null || r === void 0 ? void 0 : r.trim) === null || _a === void 0 ? void 0 : _a.call(r); })
.catch(() => null);
if (rotation === 'ROTATION_0')
orientation = 'portrait';
else if (rotation === 'ROTATION_90')
orientation = 'landscape-secondary';
else if (rotation === 'ROTATION_180')
orientation = 'portrait-secondary';
else if (rotation === 'ROTATION_270')
orientation = 'landscape';
}
if (!orientation) {
this._logger.log('Extracting device orientation');
orientation = await this._spec.getOrientation(this.target);
}
this._logger.log('Extracted device orientation:', orientation);

@@ -559,0 +596,0 @@ return orientation;

@@ -42,12 +42,5 @@ "use strict";

if (this._spec.isElement(options.element)) {
let elementToUse = options.element;
if (options.root) {
elementToUse = options.root;
this._target = elementToUse;
}
else {
this._target = (_c = (_b = (_a = this._spec).transformElement) === null || _b === void 0 ? void 0 : _b.call(_a, elementToUse)) !== null && _c !== void 0 ? _c : elementToUse;
}
this._target = (_c = (_b = (_a = this._spec).transformElement) === null || _b === void 0 ? void 0 : _b.call(_a, options.element)) !== null && _c !== void 0 ? _c : options.element;
// Some frameworks contains information about the selector inside an element
this._selector = (_d = options.selector) !== null && _d !== void 0 ? _d : (_f = (_e = this._spec).extractSelector) === null || _f === void 0 ? void 0 : _f.call(_e, elementToUse);
this._selector = (_d = options.selector) !== null && _d !== void 0 ? _d : (_f = (_e = this._spec).extractSelector) === null || _f === void 0 ? void 0 : _f.call(_e, options.element);
this._index = options.index;

@@ -61,2 +54,5 @@ }

}
if (this._selector && this._spec.untransformSelector) {
this._commonSelector = this._spec.untransformSelector(this._spec.transformSelector(this._selector));
}
}

@@ -69,2 +65,8 @@ get target() {

}
get commonSelector() {
return this._commonSelector;
}
get index() {
return this._index;
}
get context() {

@@ -224,4 +226,4 @@ return this._context;

}
if (contentRegion.y < this.driver.statusBarHeight) {
this._state.contentSize.height -= this.driver.statusBarHeight - contentRegion.y;
if (contentRegion.y < this.driver.statusBarSize) {
this._state.contentSize.height -= this.driver.statusBarSize - contentRegion.y;
}

@@ -284,2 +286,7 @@ return this._state.contentSize;

}
async getShadowRoot() {
if (!this.driver.isWeb)
return null;
return this._spec.executeScript(this.context.target, snippets.getShadowRoot, [this.target]);
}
async getTouchPadding() {

@@ -286,0 +293,0 @@ var _a, _b;

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.visit = exports.getTitle = exports.getUrl = exports.getOrientation = exports.setWindowSize = exports.getWindowSize = exports.getDriverInfo = exports.takeScreenshot = exports.childContext = exports.parentContext = exports.mainContext = exports.findElements = exports.findElement = exports.executeScript = exports.isEqualElements = exports.isStaleElementError = exports.transformSelector = exports.isSelector = exports.isElement = exports.isDriver = void 0;
exports.visit = exports.getTitle = exports.getUrl = exports.getOrientation = exports.setWindowSize = exports.getWindowSize = exports.getDriverInfo = exports.takeScreenshot = exports.childContext = exports.parentContext = exports.mainContext = exports.findElements = exports.findElement = exports.executeScript = exports.isEqualElements = exports.isStaleElementError = exports.extractSelector = exports.untransformSelector = exports.transformSelector = exports.isSelector = exports.isElement = exports.isDriver = void 0;
const utils = __importStar(require("@applitools/utils"));

@@ -45,2 +45,20 @@ function isDriver(driver) {

exports.transformSelector = transformSelector;
function untransformSelector(selector) {
if (utils.types.isString(selector)) {
return { type: 'css', selector: selector };
}
else if (utils.types.has(selector, ['using', 'value'])) {
return { type: selector.using === 'css selector' ? 'css' : selector.using, selector: selector.value };
}
else if (utils.types.has(selector, ['selector'])) {
return selector;
}
}
exports.untransformSelector = untransformSelector;
function extractSelector(element) {
if (utils.types.has(element, ['selector'])) {
return element.selector;
}
}
exports.extractSelector = extractSelector;
function isStaleElementError() {

@@ -47,0 +65,0 @@ return false;

{
"name": "@applitools/driver",
"version": "1.9.7",
"version": "1.9.8",
"description": "Applitools universal framework wrapper",

@@ -81,3 +81,3 @@ "keywords": [

"@applitools/snippets": "2.4.3",
"@applitools/types": "1.5.4",
"@applitools/types": "1.5.5",
"@applitools/utils": "1.3.9"

@@ -84,0 +84,0 @@ },

@@ -37,7 +37,7 @@ /// <reference types="node" />

get userAgent(): string;
get orientation(): 'portrait' | 'landscape';
get orientation(): 'portrait' | 'landscape' | 'portrait-secondary' | 'landscape-secondary';
get pixelRatio(): number;
get viewportScale(): number;
get statusBarHeight(): number;
get navigationBarHeight(): number;
get statusBarSize(): number;
get navigationBarSize(): number;
get isNative(): boolean;

@@ -63,6 +63,7 @@ get isWeb(): boolean;

takeScreenshot(): Promise<Buffer>;
getViewportRegion(): Promise<types.Region>;
getViewportSize(): Promise<types.Size>;
setViewportSize(size: types.Size): Promise<void>;
getDisplaySize(): Promise<types.Size>;
getOrientation(): Promise<'portrait' | 'landscape'>;
getOrientation(): Promise<'portrait' | 'landscape' | 'portrait-secondary' | 'landscape-secondary'>;
setOrientation(orientation: 'portrait' | 'landscape'): Promise<void>;

@@ -69,0 +70,0 @@ getCookies(): Promise<types.Cookie[]>;

@@ -16,2 +16,3 @@ import type * as types from '@applitools/types';

private _selector;
private _commonSelector?;
private _index;

@@ -29,6 +30,7 @@ private _state;

logger?: Logger;
root?: TElement;
});
get target(): TElement;
get selector(): types.Selector<TSelector>;
get commonSelector(): types.Selector<never>;
get index(): number;
get context(): Context<TDriver, TContext, TElement, TSelector>;

@@ -46,2 +48,3 @@ get driver(): import("./driver").Driver<TDriver, TContext, TElement, TSelector>;

isRoot(): Promise<boolean>;
getShadowRoot(): Promise<TElement>;
getTouchPadding(): Promise<number>;

@@ -48,0 +51,0 @@ getText(): Promise<string>;

@@ -9,2 +9,6 @@ /// <reference types="node" />

};
declare type CommonSelector = string | {
selector: Selector | string;
type?: string;
};
export declare function isDriver(driver: any): driver is Driver;

@@ -16,2 +20,4 @@ export declare function isElement(element: any): element is Element;

}): Selector;
export declare function untransformSelector(selector: Selector): CommonSelector;
export declare function extractSelector(element: Element): any;
export declare function isStaleElementError(): boolean;

@@ -33,1 +39,2 @@ export declare function isEqualElements(_driver: Driver, element1: Element, element2: Element): Promise<boolean>;

export declare function visit(driver: Driver, url: string): Promise<void>;
export {};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc