UNPKG

@salesforce/salesforcedx-vscode-test-tools

Version:
47 lines 1.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.standardPredicates = void 0; exports.createPredicateWithTimeout = createPredicateWithTimeout; const workbench_1 = require("../ui-interaction/workbench"); /** * Standard predicate functions for common scenarios */ exports.standardPredicates = { /** * A predicate that always returns true * Useful for testing or as a default value */ alwaysTrue: async () => true, /** * Waits for an element to be displayed * @param selector - The locator for the element to wait for * @returns true when the element is displayed */ waitForElement: async (selector) => { return await (0, workbench_1.getBrowser)().findElement(selector).isDisplayed(); }, /** * Polls until a condition is true * @param condition - A function that returns true when the desired condition is met * @returns true when the condition is satisfied */ waitForCondition: async (condition) => { while (!condition()) { await new Promise(resolve => setTimeout(resolve, 100)); // Adjust polling interval as needed } return true; } }; /** * Creates a predicate with an associated timeout * @param predicate - The function to evaluate * @param maxWaitTime - Maximum time to wait for the predicate to return true * @returns A PredicateWithTimeout object */ function createPredicateWithTimeout(predicate, maxWaitTime) { return { predicate, maxWaitTime }; } //# sourceMappingURL=predicates.js.map