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
33
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.35 to 1.10.0

89

dist/driver.js

@@ -120,6 +120,10 @@ "use strict";

var _a, _b;
return (_b = (_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.isNative) !== null && _b !== void 0 ? _b : false;
return (_b = (!this.isWebView && ((_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.isNative))) !== null && _b !== void 0 ? _b : false;
}
get isWebView() {
var _a, _b;
return (_b = (_a = this._driverInfo) === null || _a === void 0 ? void 0 : _a.isWebView) !== null && _b !== void 0 ? _b : false;
}
get isWeb() {
return !this.isNative;
return this.isWebView || !this.isNative;
}

@@ -160,2 +164,4 @@ get isMobile() {

(_g = (await this.getOrientation().catch(() => undefined))) !== null && _g !== void 0 ? _g : this._driverInfo.orientation;
const world = this.isMobile && (await this.getCurrentWorld());
this._driverInfo.isWebView = !!(world === null || world === void 0 ? void 0 : world.isWebView);
}

@@ -276,2 +282,81 @@ if (this.isWeb) {

}
// begin world
//
// About the concept of a "World":
//
// Since "context" is an overloaded term from frames, we have decided to use
// the concept of a "world" when switching between mobile app contexts (e.g., native and webview(s))
//
// Notes:
// - two new functions need to be added to a spec driver for this to work (`getCurrentWorld` and `switchWorld`)
// - you can see a reference implementation of this in spec-driver-webdriverio
// - if a world id is provided it will be used for switching
// - if a world id is not provided, the first non-native world will be used
// (regardless of which world the driver is currently switched into)
// - before switching, the current world context is stored so it can switched back to later
// (with the `restoreState` option)
// - the native app world can be switched to (with the `goHome` option)
async switchWorld(options) {
var _a, _b;
if ((options === null || options === void 0 ? void 0 : options.restoreState) && !this._previousWorld)
return;
if (!this._spec.getCurrentWorld || !this._spec.switchWorld) {
this._logger.warn('world switching not implemented in the spec driver, skipping');
return;
}
this._logger.log('switchWorld called with', options ? options : 'no options');
const { id, home, next } = await this.getCurrentWorld();
if (!this._previousWorld) {
this._logger.log('storing current world id for future restoration', id);
this._previousWorld = id;
}
const providedTarget = (options === null || options === void 0 ? void 0 : options.restoreState)
? this._previousWorld
: (options === null || options === void 0 ? void 0 : options.goHome)
? home
: (options === null || options === void 0 ? void 0 : options.id)
? options.id
: next;
this._logger.log('switching world with', providedTarget ? providedTarget : 'no id');
try {
await ((_b = (_a = this._spec).switchWorld) === null || _b === void 0 ? void 0 : _b.call(_a, this.target, providedTarget));
await this.init();
}
catch (error) {
throw new Error(`Unable to switch worlds, the original error was: ${error.message}`);
}
}
async getWorlds(attempt = 1) {
var _a, _b;
if (!this._spec.getWorlds)
return;
this._logger.log('attempting to find worlds');
await utils.general.sleep(500);
const worlds = await ((_b = (_a = this._spec).getWorlds) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
if (!worlds[1]) {
if (attempt > 5) {
this._logger.warn(`just one world found - ${worlds}. done looking.`);
return worlds;
}
this._logger.log(`just one world found, retrying to see if there are others (attempt #${attempt})`);
return this.getWorlds(attempt++);
}
this._logger.log(`worlds found - ${worlds}`);
return worlds;
}
async getCurrentWorld() {
var _a, _b;
if (!this._spec.getCurrentWorld)
return;
const [origin, next] = await this.getWorlds();
const currentWorld = await ((_b = (_a = this._spec).getCurrentWorld) === null || _b === void 0 ? void 0 : _b.call(_a, this.target));
return {
id: currentWorld,
home: origin,
next,
isNative: currentWorld === origin,
isWebView: currentWorld !== origin,
};
}
// end world
async refreshContexts() {

@@ -278,0 +363,0 @@ if (this.isNative)

6

package.json
{
"name": "@applitools/driver",
"version": "1.9.35",
"version": "1.10.0",
"description": "Applitools universal framework wrapper",

@@ -90,5 +90,5 @@ "keywords": [

"dependencies": {
"@applitools/logger": "1.1.23",
"@applitools/logger": "1.1.24",
"@applitools/snippets": "2.4.5",
"@applitools/types": "1.5.16",
"@applitools/types": "1.5.17",
"@applitools/utils": "1.3.12",

@@ -95,0 +95,0 @@ "semver": "7.3.7"

@@ -22,2 +22,3 @@ /// <reference types="node" />

private _helper?;
private _previousWorld;
protected readonly _spec: types.SpecDriver<TDriver, TContext, TElement, TSelector>;

@@ -45,2 +46,3 @@ constructor(options: DriverOptions<TDriver, TContext, TElement, TSelector>);

get isNative(): boolean;
get isWebView(): boolean;
get isWeb(): boolean;

@@ -54,2 +56,9 @@ get isMobile(): boolean;

init(): Promise<this>;
switchWorld(options?: {
id?: string;
restoreState?: boolean;
goHome?: boolean;
}): Promise<void>;
getWorlds(attempt?: number): Promise<string[]>;
getCurrentWorld(): Promise<types.WorldInfo>;
refreshContexts(): Promise<Context<TDriver, TContext, TElement, TSelector>>;

@@ -56,0 +65,0 @@ switchTo(context: Context<TDriver, TContext, TElement, TSelector>): Promise<Context<TDriver, TContext, TElement, TSelector>>;

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