"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ojTrain = exports.OjTrain = void 0;
const __1 = require("../../");
const OjTrain_1 = require("./OjTrain");
Object.defineProperty(exports, "OjTrain", { enumerable: true, get: function () { return OjTrain_1.OjTrain; } });
/**
 * Retrieve an instance of [OjTrain](../classes/elements.OjTrain.html).
 * @example
 * ```javascript
 * import { ojTrain } from '@oracle/oraclejet-webdriver/elements';
 * const el = await ojTrain(driver, By.id('my-oj-train'));
 * ```
 * @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 ojTrain(driver, by) {
    const webEl = await driver.findElement(by);
    // Check that the element is of type OjTrain
    if (!(webEl instanceof OjTrain_1.OjTrain)) {
        const tagName = await webEl.getTagName();
        let supplemental = '';
        if (webEl.constructor.name === 'OjTrain') {
            supplemental = 'You likely have multiple installations of this package.';
        }
        throw Error(`ojTrain(${by}) created ${webEl.constructor.name} for <${tagName}>, but expected ${OjTrain_1.OjTrain.name}. ${supplemental}`);
    }
    return webEl;
}
exports.ojTrain = ojTrain;
(0, __1.register)('oj-train', OjTrain_1.OjTrain);
//# sourceMappingURL=index.js.map