from __future__ import annotations

from playwright.sync_api import sync_playwright


def main() -> None:
    with sync_playwright() as p:
        browser = p.chromium.launch(headless=False)
        page = browser.new_page()
        page.goto("https://test-saas-adminui.lianlianwz.com/pages/login/index", wait_until="domcontentloaded")
        page.wait_for_timeout(1500)
        page.locator("input[type='text']").first.fill("wangss")
        page.locator("input[type='password']").first.fill("123456")
        page.get_by_text("登录", exact=False).first.click()
        page.wait_for_timeout(4000)

        page.get_by_text("产品管理", exact=True).first.click()
        page.wait_for_timeout(1000)
        page.get_by_text("产品申请列表", exact=True).click()
        page.wait_for_timeout(3000)

        page.get_by_placeholder("请输入商户ID").fill("99")
        page.get_by_placeholder("请输入产品ID").fill("12")
        page.get_by_text("查询", exact=True).click()
        page.wait_for_timeout(3000)

        print(page.locator("body").inner_text(timeout=10000))
        print("ROWS", page.locator(".ant-table-row").count())
        page.screenshot(path="reports/product-application-merchant99-product12.png", full_page=True)
        browser.close()


if __name__ == "__main__":
    main()
