@progress/kendo-e2e
Version:
Kendo UI end-to-end test utilities.
152 lines (151 loc) • 5.3 kB
TypeScript
import { ThenableWebDriver } from "selenium-webdriver";
import { Options as ChromeOptions } from "selenium-webdriver/chrome";
import { Options as EdgeOptions } from "selenium-webdriver/edge";
import { Options as FirefoxOptions } from "selenium-webdriver/firefox";
import { Options as SafariOptions } from "selenium-webdriver/safari";
/**
* Options for configuring WebDriver instances.
*/
export interface DriverOptions {
/** Mobile device emulation settings */
mobileEmulation?: {
deviceName: string;
} | {
width: number;
height: number;
pixelRatio: number;
} | any;
/** Enable BiDi (Bidirectional communication) protocol */
enableBidi?: boolean;
}
/**
* Factory class for creating and configuring Selenium WebDriver instances.
*
* Handles browser-specific configuration and provides pre-configured drivers for different browsers.
* Automatically applies settings from environment variables and Settings class.
*
* **Supported browsers:**
* - Chrome (with mobile emulation and BiDi support)
* - Edge
* - Firefox
* - Safari
* - BrowserStack (cloud testing)
*
* @example
* ```typescript
* // Get default driver (from Settings.browserName)
* const manager = new DriverManager();
* const driver = manager.getDriver();
*
* // Get driver with mobile emulation
* const mobileDriver = manager.getDriver({
* mobileEmulation: { deviceName: 'iPhone 14 Pro Max' }
* });
*
* // Get driver with BiDi enabled
* const bidiDriver = manager.getDriver({ enableBidi: true });
*
* // Get specific browser driver
* const chromeDriver = manager.getChromeDriver();
* const firefoxDriver = manager.getFirefoxDriver();
* ```
*/
export declare class DriverManager {
/**
* Default command-line arguments for Chromium-based browsers (Chrome, Edge).
*
* These options ensure consistent test behavior:
* - Fixed window size and scale factor for consistent screenshots
* - Disabled extensions and notifications to avoid interference
* - Reduced logging noise
* - Certificate error handling
* - Disabled search engine choice screen
*/
DEFAULT_CHROMIUM_OPTIONS: string[];
/**
* Creates a WebDriver instance based on Settings.browserName.
*
* Automatically selects the appropriate browser driver based on configuration.
* Supports mobile emulation and BiDi protocol for Chrome.
*
* @param options - Optional driver configuration
* @param options.mobileEmulation - Mobile device emulation settings (Chrome only)
* @param options.enableBidi - Enable BiDi protocol for advanced features (Chrome only)
* @returns Configured WebDriver instance
*
* @example
* ```typescript
* const manager = new DriverManager();
*
* // Basic driver
* const driver = manager.getDriver();
*
* // With mobile emulation
* const mobile = manager.getDriver({
* mobileEmulation: { deviceName: 'Pixel 5' }
* });
*
* // With BiDi for CDP features
* const advanced = manager.getDriver({ enableBidi: true });
* ```
*/
getDriver(options?: DriverOptions): ThenableWebDriver;
/**
* Creates Chrome-specific options with custom arguments and settings.
*
* Configures Chrome with optimal settings for testing, including headless mode
* support, Docker compatibility, mobile emulation, and BiDi protocol.
*
* @param args - Command-line arguments for Chrome (default: DEFAULT_CHROMIUM_OPTIONS)
* @param options - Driver configuration options
* @returns Configured ChromeOptions instance
*
* @example
* ```typescript
* const manager = new DriverManager();
*
* // Get default options
* const options = manager.getChromeOptions();
*
* // Custom arguments
* const customOptions = manager.getChromeOptions([
* '--window-size=1920,1080',
* '--disable-gpu'
* ]);
*
* // With mobile emulation
* const mobileOptions = manager.getChromeOptions(
* manager.DEFAULT_CHROMIUM_OPTIONS,
* { mobileEmulation: { deviceName: 'iPhone 12' } }
* );
* ```
*/
getChromeOptions(args?: string[], options?: DriverOptions): ChromeOptions;
/**
* Creates a Chrome WebDriver instance.
*
* @param options - Either pre-configured ChromeOptions or DriverOptions
* @returns Chrome WebDriver instance
*
* @example
* ```typescript
* const manager = new DriverManager();
*
* // Basic Chrome driver
* const driver = manager.getChromeDriver();
*
* // With custom options
* const options = manager.getChromeOptions();
* options.addArguments('--start-maximized');
* const driver = manager.getChromeDriver(options);
* ```
*/
getChromeDriver(options?: ChromeOptions | DriverOptions): ThenableWebDriver;
getEdgeOptions(args?: string[]): EdgeOptions;
getEdgeDriver(options?: EdgeOptions): ThenableWebDriver;
getFirefoxOptions(): FirefoxOptions;
getFirefoxDriver(options?: FirefoxOptions): ThenableWebDriver;
getSafariOptions(): SafariOptions;
getSafariDriver(options?: SafariOptions): ThenableWebDriver;
getBrowserStackDriver(): ThenableWebDriver;
}