@vibe/testkit
Version:
Vibe e2e testing toolkit
41 lines • 2.02 kB
JavaScript
;
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Combobox = void 0;
const BaseElement_1 = require("./BaseElement");
const Search_1 = require("./Search");
const ListItem_1 = require("./ListItem");
class Combobox extends BaseElement_1.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_1.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_1.ListItem(this.page, this.locator.locator(`[role='listbox']:has-text("${item}")`), `Select Combobox Item: ${item}`);
yield comboBoxItem.click();
});
}
}
exports.Combobox = Combobox;
//# sourceMappingURL=Combobox.js.map