"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ojButton = exports.OjButton = void 0;
const __1 = require("../../");
const OjButton_1 = require("./OjButton");
Object.defineProperty(exports, "OjButton", { enumerable: true, get: function () { return OjButton_1.OjButton; } });
/**
 * Retrieve an instance of [OjButton](../classes/elements.OjButton.html).
 * @example
 * ```javascript
 * import { ojButton } from '@oracle/oraclejet-webdriver/elements';
 * const el = await ojButton(driver, By.id('my-oj-button'));
 * ```
 * @param driver A WebDriver/WebElement instance from where the element will be
 * searched. If WebDriver is passed, the element will be searched globally in the
 * document. If WebElement is passed, the search will be relative to this element.
 * @param by The locator with which to find the element
 */
async function ojButton(driver, by) {
    const webEl = await driver.findElement(by);
    // Check that the element is of type OjButton
    if (!(webEl instanceof OjButton_1.OjButton)) {
        const tagName = await webEl.getTagName();
        let supplemental = '';
        if (webEl.constructor.name === 'OjButton') {
            supplemental = 'You likely have multiple installations of this package.';
        }
        throw Error(`ojButton(${by}) created ${webEl.constructor.name} for <${tagName}>, but expected ${OjButton_1.OjButton.name}. ${supplemental}`);
    }
    return webEl;
}
exports.ojButton = ojButton;
(0, __1.register)('oj-button', OjButton_1.OjButton);
//# sourceMappingURL=index.js.map