Files
QSfera/Desktop/test/gui/helpers/WebUIHelper.py
Курнат Андрей 2315f25754 Initial QSfera import
2026-06-07 10:20:04 +03:00

21 lines
646 B
Python

import pyperclip
from playwright.sync_api import sync_playwright
def authorize_via_webui(username, password):
url = pyperclip.paste()
with sync_playwright() as pw:
browser = pw.chromium.launch(headless=True)
context = browser.new_context(ignore_https_errors=True)
page = context.new_page()
page.goto(url)
page.fill('#oc-login-username', username)
page.fill('#oc-login-password', password)
page.click('button :text("Log in")')
page.click('button :text("Allow")')
page.wait_for_selector(':text("Login successful")')
context.close()
browser.close()