UNPKG

@scraping.house/commons

Version:
50 lines 1.82 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const abstract_sub_module_1 = __importDefault(require("./abstract-sub-module")); const logger_1 = require("../utils/logger"); const url_factory_1 = __importDefault(require("../utils/url-factory")); class AbstractUserProfileModule extends abstract_sub_module_1.default { constructor(selectors, baseURL, id, page) { super(page, baseURL); this.id = id; this.selectors = selectors; this.urlFactory = new url_factory_1.default(baseURL); } async init() { const u = this.urlFactory.get(this.id); if (this.page.url() == u) { return; } await this.page.goto(u); AbstractUserProfileModule.logger.log('Navigated to the user profile page'); } /** * Returns the fullname of the user * @returns The full name of the user */ async fullName() { return this.getTextualContent(this.selectors.fullName); } /** * Returns the bio of the current user * @returns The bio of the current user */ async bio() { return this.getTextualContent(this.selectors.bio); } /** * Returns the text content of the given selector * @param selector The selector the get text content of * @returns The text cotnent of the given selector */ async getTextualContent(selector) { await this.init(); return this.page.textContent(selector); } } exports.default = AbstractUserProfileModule; AbstractUserProfileModule.logger = new logger_1.Logger('AbstractUserProfileModule'); //# sourceMappingURL=abstract-user-profile-module.js.map