UNPKG

imm-noc

Version:

A tool for noc inquiry

43 lines (42 loc) 1.88 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 }); exports.Go = void 0; class Go { constructor(args) { this.noc = args.noc; this.page = args.page; this.url = args.url; this.input_box = args.input_box; this.search_button = args.search_button; } go() { return __awaiter(this, void 0, void 0, function* () { yield this.page.goto(this.url); yield this.page.click(this.input_box, { clickCount: 3 }); yield this.page.type(this.input_box, this.noc); yield this.page.waitForTimeout(500); yield this.page.keyboard.press("ArrowDown"); const changed = yield this.page.waitForFunction((noc, id2) => { const text = document.querySelector(id2).textContent; return text != noc; }, {}, this.noc, this.input_box); if (changed) { yield this.page.keyboard.press("Enter"); yield Promise.all([ this.page.click(this.search_button), this.page.waitForNavigation() ]); } }); } } exports.Go = Go;