| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- """Debug: after clicking the login button, observe what actually happens.
- Three things to check:
- 1. Did the URL change (login button actually triggered a state change)?
- 2. Are there any error messages visible (form validation failed)?
- 3. What geetest-related elements are present (correct class names)?
- """
- import asyncio
- import sys
- from pathlib import Path
- _HERE = Path(__file__).resolve().parent
- sys.path.insert(0, str(_HERE.parent / "src"))
- from playwright.async_api import async_playwright
- EDGE = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
- URL = "https://pc.hzwlan.com/login/account"
- async def main():
- out = _HERE / "jfbym_diag"
- async with async_playwright() as p:
- browser = await p.chromium.launch(executable_path=EDGE, headless=True)
- ctx = await browser.new_context(viewport={"width": 1366, "height": 768})
- page = await ctx.new_page()
- await page.goto(URL, wait_until="networkidle", timeout=30000)
- await page.fill("input#username", "longwu988")
- await page.fill("input#password", "Longwu1988")
- btn = page.locator("button.login-form_box__submit_button").first
- await btn.click(force=True)
- # Give the page time to react (geetest async-load, or error to render)
- await page.wait_for_timeout(5000)
- await page.screenshot(path=str(out / "a1_after_click.png"), full_page=True)
- info = await page.evaluate("""() => {
- return {
- url: location.href,
- title: document.title,
- errors: [...document.querySelectorAll(
- '.ant-form-item-explain-error, .ant-message-error, .error-msg, [class*=error]'
- )].map(e => ({cls: e.className, text: (e.innerText||'').trim().slice(0,80)})),
- geetest_any: !!document.querySelector('[class*=geetest], iframe[src*=geetest]'),
- geetest_els: [...document.querySelectorAll(
- '[class*=geetest]'
- )].slice(0, 10).map(e => ({tag:e.tagName, cls:e.className.slice(0,60)})),
- captcha: !!document.querySelector('.geetest_captcha, .geetest_captcha_refresh'),
- iframes: [...document.querySelectorAll('iframe')].map(i => i.src.slice(0, 80)),
- };
- }""")
- print(f"url after click: {info['url']}")
- print(f"title: {info['title']}")
- print(f"geetest_any: {info['geetest_any']}")
- print(f"geetest_els: {info['geetest_els']}")
- print(f"captcha: {info['captcha']}")
- print(f"errors ({len(info['errors'])}): {info['errors']}")
- print(f"iframes: {info['iframes']}")
- await browser.close()
- print(f"\nscreenshot: {out / 'a1_after_click.png'}")
- asyncio.run(main())
|