🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@redhat-developer/page-objects

Package Overview
Dependencies
Maintainers
11
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redhat-developer/page-objects - npm Package Compare versions

Comparing version

to
1.12.0

6

out/components/bottomBar/WebviewView.d.ts

@@ -17,3 +17,3 @@ /**

*/
import { WebElement } from 'selenium-webdriver';
import { Locator, WebElement } from 'selenium-webdriver';
import { AbstractElement } from '../AbstractElement';

@@ -24,4 +24,4 @@ /**

declare class WebviewViewBase extends AbstractElement {
constructor();
getViewToSwitchTo(handle: string): Promise<WebElement | undefined>;
constructor(base?: Locator | WebElement, enclosingItem?: WebElement | Locator);
getViewToSwitchTo(): Promise<WebElement | undefined>;
}

@@ -28,0 +28,0 @@ export declare const WebviewView: new (...args: any[]) => WebviewViewBase & import("../WebviewMixin").WebviewMixinType;

@@ -25,2 +25,3 @@ "use strict";

const WebviewMixin_1 = __importDefault(require("../WebviewMixin"));
const locators_1 = require("../../locators/locators");
/**

@@ -30,8 +31,8 @@ * Page object representing a user-contributed panel implemented using a Webview.

class WebviewViewBase extends AbstractElement_1.AbstractElement {
constructor() {
super(WebviewViewBase.locators.Workbench.constructor);
constructor(base = WebviewViewBase.locators.Workbench.constructor, enclosingItem) {
super(base, enclosingItem);
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getViewToSwitchTo(handle) {
return await this.getDriver().findElement(WebviewViewBase.locators.WebviewView.iframe);
async getViewToSwitchTo() {
const frames = await this.getDriver().findElements(WebviewViewBase.locators.WebView.iframe);
return (0, locators_1.findBestContainingElement)(await this.getRect(), frames);
}

@@ -38,0 +39,0 @@ }

@@ -23,3 +23,3 @@ /**

declare class WebViewBase extends Editor {
getViewToSwitchTo(handle: string): Promise<WebElement | undefined>;
getViewToSwitchTo(): Promise<WebElement | undefined>;
}

@@ -26,0 +26,0 @@ export declare const WebView: new (...args: any[]) => WebViewBase & import("../WebviewMixin").WebviewMixinType;

@@ -25,2 +25,3 @@ "use strict";

const Editor_1 = require("./Editor");
const locators_1 = require("../../locators/locators");
/**

@@ -30,13 +31,5 @@ * Page object representing an open editor containing a web view

class WebViewBase extends Editor_1.Editor {
async getViewToSwitchTo(handle) {
const handles = await this.getDriver().getAllWindowHandles();
for (const handle of handles) {
await this.getDriver().switchTo().window(handle);
if ((await this.getDriver().getTitle()).includes('Virtual Document')) {
await this.getDriver().switchTo().frame(0);
return;
}
}
await this.getDriver().switchTo().window(handle);
return await this.getDriver().findElement(WebViewBase.locators.WebView.iframe);
async getViewToSwitchTo() {
const frames = await this.getDriver().findElements(WebViewBase.locators.WebView.iframe);
return (0, locators_1.findBestContainingElement)(await this.getRect(), frames);
}

@@ -43,0 +36,0 @@ }

@@ -103,5 +103,6 @@ "use strict";

async getActions() {
await this.getDriver().actions().move({ origin: this }).perform(); // move mouse to bring auto-hided buttons visible
const actions = await this.findElement(ViewSection.locators.ViewSection.actions).findElements(ViewSection.locators.ViewSection.button);
return Promise.all(actions.map(async (action) => {
const dropdown = await action.getAttribute('aria-haspopup');
const dropdown = (await action.getAttribute('aria-haspopup')) || (await action.getAttribute('aria-expanded'));
if (dropdown) {

@@ -108,0 +109,0 @@ return new ViewPanelActionDropdown(action, this);

@@ -27,3 +27,3 @@ /**

interface WebviewMixable extends AbstractElement {
getViewToSwitchTo(handle: string): Promise<WebElement | undefined>;
getViewToSwitchTo(): Promise<WebElement | undefined>;
}

@@ -30,0 +30,0 @@ /**

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

}
const view = await this.getViewToSwitchTo(this.handle);
const view = await this.getViewToSwitchTo();
if (!view) {

@@ -69,0 +69,0 @@ return;

@@ -17,3 +17,3 @@ /**

*/
import { By, WebElement } from 'selenium-webdriver';
import { By, IRectangle, WebElement } from 'selenium-webdriver';
import { PartialDeep } from 'type-fest';

@@ -218,4 +218,2 @@ import { ViewSection } from '../components/sidebar/ViewSection';

activeFrame: By;
container: (id: string) => By;
attribute: string;
};

@@ -559,2 +557,3 @@ ExtensionEditorView: {

export declare function fromText(locator?: By): (el: WebElement) => Promise<string>;
export declare function findBestContainingElement(container: IRectangle, testElements: WebElement[]): Promise<WebElement | undefined>;
export {};

@@ -25,2 +25,3 @@ "use strict";

exports.fromText = fromText;
exports.findBestContainingElement = findBestContainingElement;
function hasAttribute(attr, value, locator) {

@@ -68,2 +69,22 @@ return async (el) => {

}
async function findBestContainingElement(container, testElements) {
const areas = await Promise.all(testElements.map(async (value) => {
const rect = await value.getRect();
const ax = Math.max(container.x, rect.x);
const ay = Math.max(container.y, rect.y);
const bx = Math.min(container.x + container.width, rect.x + rect.width);
const by = Math.min(container.y + container.height, rect.y + rect.height);
return (bx - ax) * (by - ay);
}));
let bestIdx = -1;
for (let i = 0; i < testElements.length; i++) {
if (areas[i] < 0) {
continue;
}
if (bestIdx === -1 || areas[i] > areas[bestIdx]) {
bestIdx = i;
}
}
return bestIdx === -1 ? undefined : testElements[bestIdx];
}
//# sourceMappingURL=locators.js.map
{
"name": "@redhat-developer/page-objects",
"version": "1.11.0",
"version": "1.12.0",
"description": "Page Object API implementation for a VS Code editor used by ExTester framework.",

@@ -44,3 +44,3 @@ "main": "out/index.js",

"fs-extra": "^11.3.0",
"type-fest": "^4.35.0"
"type-fest": "^4.39.1"
},

@@ -51,3 +51,3 @@ "peerDependencies": {

},
"gitHead": "bf17db769fb699fe9a47325ff6e0c94dc821ae0f"
"gitHead": "006642fd809f6b11cc662ed0f190295efff61602"
}