UNPKG

chromancer

Version:

A powerful command-line interface for automating Chrome browser using Playwright. Perfect for web scraping, automation, testing, and browser workflows.

41 lines (40 loc) 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const base_js_1 = require("../base.js"); class WaitForLogin extends base_js_1.BaseCommand { static description = 'Navigate to a URL and wait for user to complete login before continuing'; static examples = [ '<%= config.bin %> <%= command.id %> https://gmail.com', '<%= config.bin %> <%= command.id %> https://github.com --ready-selector ".Header-link--profile"', '<%= config.bin %> <%= command.id %> https://app.example.com --ready-selector "#dashboard" --profile work', ]; static flags = { ...base_js_1.BaseCommand.baseFlags, 'ready-selector': core_1.Flags.string({ char: 'r', description: 'CSS selector that indicates successful login (default: body)', default: 'body', }), timeout: core_1.Flags.integer({ char: 't', description: 'Maximum time to wait for login in milliseconds', default: 300000, // 5 minutes }), }; static args = { url: core_1.Args.string({ description: 'URL to navigate to and wait for login', required: true, }), }; async run() { const { args, flags } = await this.parse(WaitForLogin); await this.connectToChrome(flags.port, flags.host, flags.launch, flags.profile, flags.headless, flags.verbose, flags.keepOpen); if (!this.page) { this.error('Failed to connect to Chrome'); } await this.waitForLogin(args.url, flags['ready-selector']); } } exports.default = WaitForLogin;