UNPKG

@progress/kendo-e2e

Version:

Kendo UI end-to-end test utilities.

91 lines (90 loc) 3.82 kB
import { By, IRectangle, ThenableWebDriver } from "selenium-webdriver"; import { Level } from "selenium-webdriver/lib/logging"; import { WebApp } from "./web-app"; export { By, Key, ThenableWebDriver, until, WebElement, WebElementCondition } from "selenium-webdriver"; interface BrowserOptions { driver?: ThenableWebDriver; mobileEmulation?: { deviceName: string; } | { width: number; height: number; pixelRatio: number; } | any; enableBidi?: boolean; } /** * Extends the {@link WebApp} with browser based capabilities. * Essentially, we test browsers (that have nice things like {@link navigateTo}, {@link refresh} etc.), * and electron apps, that render within a webview (but have no shell with address bar, refresh button, tabs, etc), * and VSCode extensions... which is an electron app. */ export declare class Browser extends WebApp { /** * Creates an instance of the Browser class. * * @param {ThenableWebDriver | BrowserOptions} [driverOrOptions] - Either a WebDriver instance or an options object. * If a WebDriver instance is provided, it will be used as the driver. If an options object is provided, a new driver will be created with those options. * @param {Object} [mobileEmulation] - (Optional) Mobile emulation options, used only if the first parameter is a WebDriver instance. * Mobile options can be an object with either a `deviceName` or `width`, `height`, and `pixelRatio`. * @param {boolean} [enableBidi] - (Optional) Enables BiDi (Bidirectional communication) if set to `true`. * * __Usage Examples:__ * * __Example 1: Using a Pre-configured Device__ * ```typescript * const mobileEmulation = { deviceName: "iPhone 14 Pro Max" }; * const browser = new Browser(mobileEmulation); * ``` * * __Example 2: Using Custom Screen Configuration__ * ```typescript * const mobileEmulation = { deviceMetrics: { width: 360, height: 640, pixelRatio: 3.0 }, userAgent: 'My Agent' }; * const browser = new Browser(mobileEmulation); * ``` * * __Example 3: Providing a WebDriver Instance With Mobile Emulation__ * ```typescript * const driver = new Builder().forBrowser('chrome').build(); * const mobileEmulation = { deviceName: "iPhone 14 Pro Max" }; * const browser = new Browser(driver, mobileEmulation); * ``` * * __Example 4: Enabling BiDi Mode__ * ```typescript * const browser = new Browser({ enableBidi: true }); * ``` * * __Example 5: Combining Mobile Emulation and BiDi Mode__ * ```typescript * const browser = new Browser({ mobileEmulation: { deviceName: "iPhone 14 Pro Max" }, enableBidi: true }); * ``` * * [em]: https://chromedriver.chromium.org/mobile-emulation * [devem]: https://developer.chrome.com/devtools/docs/device-mode */ constructor(driverOrOptions?: ThenableWebDriver | BrowserOptions, mobileEmulation?: { deviceName: string; } | { width: number; height: number; pixelRatio: number; } | any, enableBidi?: boolean); close(): Promise<void>; navigateTo(url: string): Promise<void>; getRect(): Promise<IRectangle>; setRect(rect: { width?: number; height?: number; x?: number; y?: number; }): Promise<void>; resizeToDocumentScrollHeight(): Promise<void>; refresh(): Promise<void>; switchToIFrame(elementLocator: By): Promise<void>; getCurrentUrl(): Promise<string>; getBrowserName(): Promise<string>; getAccessibilityViolations(cssSelector?: string, disableRules?: string[]): Promise<[]>; clearLogs(): Promise<void>; getErrorLogs(excludeList?: string[], logLevel?: Level): Promise<string[]>; }