@salesforce/salesforcedx-vscode-test-tools
Version:
Test automation framework for Salesforce Extensions for VS Code
41 lines • 1.77 kB
JavaScript
;
/*
* Copyright (c) 2025, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.clickButtonOnModalDialog = void 0;
const vscode_extension_tester_1 = require("vscode-extension-tester");
const retryUtils_1 = require("../retryUtils");
const core_1 = require("../core");
/**
* Clicks a button on a modal dialog with the specified button text.
*
* @param buttonText - The text of the button to be clicked on the modal dialog.
* @returns A promise that resolves when the button click action is completed.
* @throws Will throw an error if the modal dialog is undefined.
*/
const clickButtonOnModalDialog = async (buttonText, failOnError = true) => {
await (0, core_1.pause)(core_1.Duration.seconds(2));
const pushButton = async () => {
(0, core_1.log)(`clickButtonOnModalDialog() - Pushing button with text: "${buttonText}"`);
const modalDialog = new vscode_extension_tester_1.ModalDialog();
await (0, core_1.pause)(core_1.Duration.seconds(2)); // wait for the modal dialog to be visible
await modalDialog.pushButton(buttonText);
};
if (failOnError) {
await (0, retryUtils_1.retryOperation)(pushButton, 3, 'clickButtonOnModalDialog() - Error pushing button');
}
else {
try {
await pushButton();
}
catch (error) {
(0, core_1.log)(`clickButtonOnModalDialog() - Error pushing button ${buttonText}: ${error}`);
}
}
};
exports.clickButtonOnModalDialog = clickButtonOnModalDialog;
//# sourceMappingURL=modalDialog.js.map