import { Locator } from 'selenium-webdriver';
import { OjConveyorBeltBase } from './OjConveyorBeltBase';

/**
 * The component WebElement for [oj-conveyor-belt](../../jsdocs/oj.ojConveyorBelt.html).
 * Do not instantiate this class directly, instead, use
 * [ojConveyorBelt](../functions/elements.ojConveyorBelt-1.html).
 */
export class OjConveyorBelt extends OjConveyorBeltBase {
  // Put overrides here

  /**
   * Scroll the conveyor belt, so that the conveyor belt's element (button, tab bar) of interest is in the view
   *
   * @param {Locator} locator The lookup to pass into findElement
   */
  async scrollElementIntoView(locator: Locator): Promise<void> {
    await this.whenReady();
    let el = await this.findElement(locator);
    return await this.getDriver().executeScript(
      ['var cb = arguments[0];', 'var el = arguments[1];', 'cb.scrollElementIntoView(el);'].join(
        '\n'
      ),
      this,
      el
    );
  }
}
