UNPKG

@vibe/testkit

Version:
37 lines 1.85 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { BaseElement } from "./BaseElement"; import { Search } from "./Search"; import { ListItem } from "./ListItem"; export class Combobox extends BaseElement { /** * Create a Combobox. * @param {Page} page - The Playwright page object. * @param {Locator} locator - The locator for the Combobox element. * @param {string} elementReportName - The name for reporting purposes. */ constructor(page, locator, elementReportName) { super(page, locator, elementReportName); this.searchInput = new Search(page, this.locator.locator("[role='search']"), `${elementReportName} Search Input`); } /** * Select an item from the combobox. * @param {string} item - The name of the item to select. * @returns {Promise<void>} */ selectItem(item) { return __awaiter(this, void 0, void 0, function* () { yield this.searchInput.setText(item); const comboBoxItem = new ListItem(this.page, this.locator.locator(`[role='listbox']:has-text("${item}")`), `Select Combobox Item: ${item}`); yield comboBoxItem.click(); }); } } //# sourceMappingURL=Combobox.js.map