import http from 'node:http'; import https from 'node:https'; import type { Capabilities, Frameworks, Options } from '@wdio/types'; import type { BeforeCommandArgs, AfterCommandArgs } from '@wdio/reporter'; import type { Method } from 'got'; import type { ColorName } from 'chalk'; import type { UploadType, LaunchResponse, BrowserstackConfig } from './types.js'; import type { ITestCaseHookParameter } from './cucumber-types.js'; import type { StartBinSessionResponse } from './grpc/index.js'; export type GitMetaData = { name: string; sha: string; short_sha: string; branch: string; tag: string | null; committer: string; committer_date: string; author: string; author_date: string; commit_message: string; root: string; common_git_dir: string; worktree_git_dir: string; last_tag: string | null; commits_since_last_tag: number; remotes: Array<{ name: string; url: string; }>; }; export declare const DEFAULT_REQUEST_CONFIG: { agent: { http: http.Agent; https: https.Agent; }; headers: { 'Content-Type': string; 'X-BSTACK-OBS': string; }; }; export declare const COLORS: Record; /** * get browser description for Browserstack service * @param cap browser capablities */ export declare function getBrowserDescription(cap: Capabilities.DesiredCapabilities): string; /** * get correct browser capabilities object in both multiremote and normal setups * @param browser browser object * @param caps browser capbilities object. In case of multiremote, the object itself should have a property named 'capabilities' * @param browserName browser name in case of multiremote */ export declare function getBrowserCapabilities(browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, caps?: Capabilities.RemoteCapability, browserName?: string): WebdriverIO.Capabilities; /** * check for browserstack W3C capabilities. Does not support legacy capabilities * @param cap browser capabilities */ export declare function isBrowserstackCapability(cap?: WebdriverIO.Capabilities): boolean; export declare function getParentSuiteName(fullTitle: string, testSuiteTitle: string): string; export declare function o11yErrorHandler(fn: Function): (...args: any) => any; export declare function errorHandler(fn: Function): (...args: any) => any; export declare function nodeRequest(requestType: Method, apiEndpoint: string, options: any, apiUrl: string, timeout?: number): Promise; type ClassType = { new (...args: any[]): any; }; export declare function o11yClassErrorHandler(errorClass: T): T; export declare const processTestObservabilityResponse: (response: LaunchResponse) => void; export declare const performO11ySync: (browser: WebdriverIO.Browser) => Promise; interface DataElement { [key: string]: any; } export declare const jsonifyAccessibilityArray: (dataArray: DataElement[], keyName: keyof DataElement, valueName: keyof DataElement) => Record; export declare const processAccessibilityResponse: (response: LaunchResponse | StartBinSessionResponse, options: BrowserstackConfig & Options.Testrunner) => void; export declare const processLaunchBuildResponse: (response: LaunchResponse, options: BrowserstackConfig & Options.Testrunner) => void; export type CentralUser = { app_lcnc: boolean; }; export declare const getCentralUser: () => Partial; export declare const launchTestSession: (...args: any[]) => any; export declare const validateCapsWithAppA11y: (platformMeta?: { [key: string]: any; }) => boolean; export declare const validateCapsWithA11y: (deviceName?: any, platformMeta?: { [key: string]: any; }, chromeOptions?: any) => boolean; export declare const validateCapsWithNonBstackA11y: (browserName?: string | undefined, browserVersion?: string | undefined) => boolean; export declare const shouldScanTestForAccessibility: (suiteTitle: string | undefined, testTitle: string, accessibilityOptions?: { [key: string]: any; }, world?: { [key: string]: any; }, isCucumber?: boolean) => boolean; export declare const isAccessibilityAutomationSession: (accessibilityFlag?: boolean | string | null) => boolean | "" | null | undefined; export declare const isAppAccessibilityAutomationSession: (accessibilityFlag?: boolean | string, isAppAutomate?: boolean) => boolean | "" | null | undefined; export declare const formatString: (template: (string | null), ...values: (string | null)[]) => string; export declare const _getParamsForAppAccessibility: (commandName?: string) => { thTestRunUuid: any; thBuildUuid: any; thJwtToken: any; authHeader: any; scanTimestamp: Number; method: string | undefined; }; export declare const performA11yScan: (isAppAutomate: boolean, browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser, isBrowserStackSession?: boolean, isAccessibility?: boolean | string, commandName?: string) => Promise<{ [key: string]: any; } | undefined>; export declare const getA11yResults: (...args: any[]) => any; export declare const getAppA11yResults: (...args: any[]) => any; export declare const getAppA11yResultsSummary: (...args: any[]) => any; export declare const getA11yResultsSummary: (...args: any[]) => any; export declare const stopBuildUpstream: (...args: any[]) => any; export declare function getCiInfo(): { name: string; build_url: string | undefined; job_name: string | undefined; build_number: string | undefined; } | { name: string; build_url: string | undefined; job_name: string | null; build_number: string | undefined; } | { name: string; build_url: null; job_name: string | undefined; build_number: string | undefined; } | { name: string; build_url: string; job_name: null; build_number: null; } | { name: string; build_url: null; job_name: null; build_number: string | undefined; } | { name: string; build_url: null; job_name: string | null; build_number: string | null; } | null; export declare function getGitMetaData(): Promise; export declare function getUniqueIdentifier(test: Frameworks.Test, framework?: string): string; export declare function getUniqueIdentifierForCucumber(world: ITestCaseHookParameter): string; export declare function isStagingEnvBsstagHost(hostname: string): boolean; export declare function getCloudProvider(browser: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): string; export declare function isBrowserstackSession(browser?: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): boolean | undefined; /** * Sets a BrowserStack annotation with the provided message * @param browser - The WebDriver browser instance * @param message - The annotation message to set * @param isAccessibilityEnabled - Whether accessibility is enabled for the session */ export declare function setBrowserstackAnnotation(browser: WebdriverIO.Browser, message: string, isAccessibilityEnabled: boolean): Promise; export declare function getScenarioExamples(world: ITestCaseHookParameter): string[] | undefined; export declare function removeAnsiColors(message: string): string; export declare function getLogTag(eventType: string): string; export declare function getHierarchy(fullTitle?: string): string[]; export declare function getHookType(hookName: string): string; export declare function isScreenshotCommand(args: BeforeCommandArgs | AfterCommandArgs): boolean | "" | undefined; export declare function isBStackSession(config: Options.Testrunner): boolean; export declare function isBrowserstackInfra(config: BrowserstackConfig & Options.Testrunner, caps?: Capabilities.BrowserStackCapabilities): boolean; export declare function shouldAddServiceVersion(config: Options.Testrunner, testObservability?: boolean, caps?: Capabilities.BrowserStackCapabilities): boolean; export declare function batchAndPostEvents(eventUrl: string, kind: string, data: UploadType[]): Promise; export declare function normalizeTestReportingConfig(_options: BrowserstackConfig & Options.Testrunner): void; export declare function normalizeTestReportingEnvVariables(): void; export declare function getObservabilityUser(options: BrowserstackConfig & Options.Testrunner, config: Options.Testrunner): string | undefined; export declare function getObservabilityKey(options: BrowserstackConfig & Options.Testrunner, config: Options.Testrunner): string | undefined; export declare function getObservabilityProject(options: BrowserstackConfig & Options.Testrunner, bstackProjectName?: string): string | undefined; export declare function getObservabilityBuild(options: BrowserstackConfig & Options.Testrunner, bstackBuildName?: string): string; export declare function getObservabilityBuildTags(options: BrowserstackConfig & Options.Testrunner, bstackBuildTag?: string): string[]; export declare function getTestPlanId(options: BrowserstackConfig & Options.Testrunner): string | undefined; export declare function getBrowserStackUser(config: Options.Testrunner): string | undefined; export declare function getBrowserStackKey(config: Options.Testrunner): string | undefined; export declare function isUndefined(value: any): boolean; export declare function isTrue(value?: any): boolean; export declare function isFalse(value?: any): boolean; /** * skipAppOverride validation chokepoint — ported from the Node SDK's * validateSkipAppOverride (helper.js) / Java BrowserStackJavaAgent.processAppOptions. * Called ONCE from the launcher (main process, pre-session). Emits the fixed warning, * handles the three edge cases, and clears the app on conflict so it is neither uploaded * nor injected. There is NO Tier-2 branch: every WebdriverIO test framework * (mocha/jasmine/cucumber) supports App Automate. * * The standard warning and the edge-2 error are verbatim with the other BrowserStack SDKs * (BrowserStackJavaAgent#processAppOptions). The edge-1 conflict warning is INTENTIONALLY adapted for * WebdriverIO — it says "browserstack service options" (where WDIO reads `app`), not "browserstack.yml" — * so please do NOT "fix" it back to the yml wording to match the other SDKs. * Graceful: never throws except the deliberate edge-2 config error (explicit false + no app), * which fires pre-session so the run aborts cleanly. * * Mutates `options.app` (edge-1). 3-state via isTrue/isFalse — never `!options.skipAppOverride`. */ export declare function validateSkipAppOverride(options?: BrowserstackConfig): void; export declare function frameworkSupportsHook(hook: string, framework?: string): boolean; export declare const patchConsoleLogs: (...args: any) => any; export declare function getFailureObject(error: string | Error): { failure: { backtrace: string[]; }[]; failure_reason: string; failure_type: string | null; }; export declare function truncateString(field: string, truncateSizeInBytes: number): string; export declare function getSizeOfJsonObjectInBytes(jsonData: GitMetaData): number; export declare function checkAndTruncateVCSInfo(gitMetaData: GitMetaData): GitMetaData; export declare const sleep: (ms?: number) => Promise; export declare function uploadLogs(user: string | undefined, key: string | undefined, clientBuildUuid: string): Promise; export declare const isObject: (object: any) => boolean; export declare function isSafeKey(key: string): boolean; export declare const ObjectsAreEqual: (object1: any, object2: any) => boolean; export declare const getPlatformVersion: (...args: any) => any; export declare const isObjectEmpty: (objectName: unknown) => unknown; export declare const getErrorString: (err: unknown) => string | undefined; export declare function isTurboScale(options: (BrowserstackConfig & Options.Testrunner) | undefined): boolean; export declare function getObservabilityProduct(options: (BrowserstackConfig & Options.Testrunner) | undefined, isAppAutomate: boolean | undefined): string; type PollingResult = { data: any; headers: Record; message?: string; }; export declare function pollApi(url: string, params: Record, headers: Record, upperLimit: number, startTime?: number): Promise; export declare function getBooleanValueFromString(value: string | undefined): boolean; /** * Validate boolean value from mixed types (boolean or string) * Only accepts true boolean or string "true" (case insensitive) */ export declare function isValidEnabledValue(value: boolean | string | undefined): boolean; export declare function mergeDeep(target: Record, ...sources: any[]): Record; export declare function mergeChromeOptions(base: Capabilities.ChromeOptions, override: Partial): Capabilities.ChromeOptions; export declare function isNullOrEmpty(string: any): boolean; export declare function isHash(entity: any): boolean; export declare function nestedKeyValue(hash: any, keys: Array): any; export declare function removeDir(dir: string): void; export declare function createDir(dir: string): void; export declare function isWritable(dirPath: string): boolean; export declare function setReadWriteAccess(dirPath: string): void; export declare function getMochaTestHierarchy(test: Frameworks.Test): string[]; /** * Mocha and Jasmine have no tag construct, so `@tag` tokens written into the suite and * test titles are the tag source. The leading `@` is kept so these match the pickle tags * the Cucumber path in this service already forwards; note the node SDK strips it for * Jest/Playwright, so the two SDKs emit different shapes for the same logical tag. */ export declare function getTestTags(test: Frameworks.Test, scopes?: string[]): string[]; /** * Checks if the capabilities represent a multiremote configuration * @param capabilities - The capabilities to check * @returns true if capabilities represent any multiremote configuration (regular or parallel) * * @example * Regular multiremote (object): * { browserA: { capabilities: {...} }, browserB: { capabilities: {...} } } * * Parallel multiremote (array with nested structure): * [{ browserA: { capabilities: {...} }, browserB: { capabilities: {...} } }] * * Regular capabilities (array): * [{ browserName: 'chrome', ... }] */ export declare function isMultiRemoteCaps(capabilities: Capabilities.RemoteCapabilities): boolean; export {}; //# sourceMappingURL=util.d.ts.map