UNPKG

flagpole

Version:

Simple and fast DOM integration, headless or headful browser, and REST API testing framework.

209 lines 8.56 kB
"use strict"; 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 }); const puppeteerelement_1 = require("./puppeteerelement"); exports.ExtJsComponentTypes = { actionsheet: "Ext.ActionSheet", audio: "Ext.Audio", button: "Ext.Button", image: "Ext.Img", label: "Ext.Label", loadmask: "Ext.LoadMask", panel: "Ext.Panel", segmentedbutton: "Ext.SegmentedButton", sheet: "Ext.Sheet", spacer: "Ext.Spacer", titlebar: "Ext.TitleBar", toolbar: "Ext.Toolbar", video: "Ext.Video", carousel: "Ext.carousel.Carousel", navigationview: "Ext.navigation.View", datepicker: "Ext.picker.Date", picker: "Ext.picker.Picker", slider: "Ext.slider.Slider", thumb: "Ext.slider.Thumb", tabpanel: "Ext.tab.Panel", viewport: "Ext.viewport.Default", dataview: "Ext.dataview.DataView", list: "Ext.dataview.List", nestedlist: "Ext.dataview.NestedList", checkboxfield: "Ext.field.Checkbox", datepickerfield: "Ext.field.DatePicker", emailfield: "Ext.field.Email", hiddenfield: "Ext.field.Hidden", numberfield: "Ext.field.Number", passwordfield: "Ext.field.Password", radiofield: "Ext.field.Radio", searchfield: "Ext.field.Search", selectfield: "Ext.field.Select", sliderfield: "Ext.field.Slider", spinnerfield: "Ext.field.Spinner", textfield: "Ext.field.Text", textareafield: "Ext.field.TextArea", togglefield: "Ext.field.Toggle", treelist: "Ext.list.Tree", urlfield: "Ext.field.Url", fieldset: "Ext.form.FieldSet", formpanel: "Ext.form.Panel" }; class ExtJsComponent extends puppeteerelement_1.PuppeteerElement { constructor(input, context, name, path) { super(input, context, name || "ExtJs Component"); this._path = path || ""; } get path() { return this._path; } get name() { return this._name || this._path || "ExtJs Component"; } get _component() { return `window.${this._input}`; } static create(referencePath, context, path) { return __awaiter(this, void 0, void 0, function* () { const element = new ExtJsComponent(referencePath, context, path, path); const componentType = (yield element.getType()).$; if (componentType !== null) { element._name = `<${componentType}> Component @ ${path}`; } return element; }); } getType() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.xtype`), `Type of ${this.name}`); }); } getId() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.getId()`), `Id of ${this.name}`); }); } getWidth() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.getSize().width`), `Width of ${this.name}`); }); } getHeight() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.getSize().height`), `Width of ${this.name}`); }); } getSize() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.getSize()`), `Size of ${this.name}`); }); } getText() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.getText()`), `Text of ${this.name}`); }); } getValue() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.getValue()`), `Value of ${this.name}`); }); } setValue(value) { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.setValue(${JSON.stringify(value)})`), `Set value of ${this.name}`); }); } setData(value) { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.setData(${JSON.stringify(value)})`), `Set data of ${this.name}`); }); } getData() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.getData()`), `Data of ${this.name}`); }); } disable() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.disable()`), `Disable ${this.name}`); }); } enable() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.enable()`), `Enable ${this.name}`); }); } hide() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.Hide()`), `Hide ${this.name}`); }); } show() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.show()`), `Show ${this.name}`); }); } focus() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.focus()`), `Focus on ${this.name}`); }); } isHidden() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.isHidden() || false`), `Is ${this.name} hidden?`); }); } isVisible() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.isVisible() || false`), `Is ${this.name} visible?`); }); } isEnabled() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.isEnabled() || false`), `Is ${this.name} enabled?`); }); } isDisabled() { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.isDisabled() || false`), `Is ${this.name} hidden?`); }); } getProperty(propertyName) { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.${propertyName}`), `${this.name}.${propertyName}`); }); } call(method, ...args) { return __awaiter(this, void 0, void 0, function* () { args.forEach((arg, i) => { args[i] = JSON.stringify(arg); }); return this._wrapAsValue(yield this._eval(`${this._component}.${method}(${args.join(",")})`), `${this.name}.${method}(${String(args)})`); }); } fireEvent(eventName) { return __awaiter(this, void 0, void 0, function* () { return this._wrapAsValue(yield this._eval(`${this._component}.fireEvent("${eventName}")`), `Fired ${eventName} on ${this.name}`); }); } click() { return __awaiter(this, void 0, void 0, function* () { return yield this._eval(`${this._component}.element.dom.click()`); }); } _eval(js) { return __awaiter(this, void 0, void 0, function* () { if (this._context.page !== null) { return yield this._context.page.evaluate(js); } throw new Error("Page was null."); }); } } exports.ExtJsComponent = ExtJsComponent; //# sourceMappingURL=extjscomponent.js.map