@vibe/testkit
Version:
Vibe e2e testing toolkit
50 lines • 2.25 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());
});
};
import { test } from "@playwright/test";
import { TextField } from "./TextField";
import { Button } from "./Button";
import { MenuButton } from "./MenuButton";
/**
* Class representing Search field element.
* Extends the BaseElement class.
*/
export class Search extends TextField {
constructor(page, locator, elementReportName, filterMenuType) {
super(page, locator, elementReportName);
this.input = new TextField(this.page, this.locator.locator("[type='search']"), `${this.elementReportName} - Input`);
this.cleanSearchButton = new Button(this.page, this.locator.locator("[aria-label='Clear']"), "Clean Button");
if (filterMenuType) {
this.filterButton = new MenuButton(this.page, this.locator.locator("[aria-label='Filters']").nth(1), "Filter Button", filterMenuType);
}
}
/**
* Set the search field text.
* @param text
*/
setText(text) {
return __awaiter(this, void 0, void 0, function* () {
yield test.step("Set text in search field", () => __awaiter(this, void 0, void 0, function* () {
yield this.input.setText(text);
}));
});
}
/**
* Clear the search field.
* @returns {Promise<void>}
*/
clear() {
return __awaiter(this, void 0, void 0, function* () {
yield test.step("Clear search field", () => __awaiter(this, void 0, void 0, function* () {
yield this.cleanSearchButton.click();
}));
});
}
}
//# sourceMappingURL=Search.js.map