cnitlrt Claude Opus 4.6 (1M context) commited on
Commit
dd7ab62
·
1 Parent(s): 1028bd7

fix: 适配 OpenAI 多种首页变体(A/B 测试)

Browse files

OpenAI 对不同 IP/地区展示不同首页:
- 变体 A: 直接有邮箱输入框(Log in or sign up)
- 变体 B: Get started + Sign up for free + 邮箱在下方
- 变体 C: Get started + Continue with Google + More options(邮箱被折叠)

现在按优先级尝试:More options → Sign up for free → Sign up → Log in,
每次点击后检查邮箱输入框是否出现。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. src/autoteam/manager.py +24 -17
src/autoteam/manager.py CHANGED
@@ -747,30 +747,37 @@ def _register_direct_once(mail_client, email, password):
747
 
748
  screenshot(page, "direct_01_login_page.png")
749
 
750
- # 可能是首页(Get started)或登录页,需要先进注册流程
 
 
 
 
 
751
  try:
752
- # 首先检查是否已经有邮箱输入框(新版统一页面)
753
- email_visible = page.locator(
754
- 'input[name="email"], input[type="email"], input[placeholder*="email" i], '
755
- 'input[placeholder*="Email" i], input[autocomplete="email"]'
756
- ).first.is_visible(timeout=3000)
757
  if not email_visible:
758
- # 尝试点击各种注册/Sign up 按钮
759
- for sel in [
760
- 'a:has-text("Sign up for free")',
761
- 'button:has-text("Sign up for free")',
762
- 'a:has-text("Sign up")',
763
- 'button:has-text("Sign up")',
764
- 'a:has-text("注册")',
765
- 'button:has-text("注册")',
 
 
 
 
766
  ]:
767
  try:
768
  btn = page.locator(sel).first
769
  if btn.is_visible(timeout=1000):
770
- logger.info("[直接注册] 点击注册按钮: %s", sel)
771
  btn.click()
772
- time.sleep(5)
773
- break
 
 
774
  except Exception:
775
  continue
776
  except Exception:
 
747
 
748
  screenshot(page, "direct_01_login_page.png")
749
 
750
+ # OpenAI 首页有多种 A/B 测试变体,需要逐步找到邮箱输
751
+ _email_selectors = (
752
+ 'input[name="email"], input[type="email"], input[id="email"], '
753
+ 'input[autocomplete="email"], input[autocomplete="username"], '
754
+ 'input[placeholder*="email" i], input[placeholder*="Email" i]'
755
+ )
756
  try:
757
+ email_visible = page.locator(_email_selectors).first.is_visible(timeout=3000)
 
 
 
 
758
  if not email_visible:
759
+ # 尝试按优先级点击各种按钮来展开/跳转到邮箱输入
760
+ for sel, desc in [
761
+ ('button:has-text("More options")', "More options"),
762
+ ('button:has-text("更多选项")', "更多选项"),
763
+ ('a:has-text("Sign up for free")', "Sign up for free"),
764
+ ('button:has-text("Sign up for free")', "Sign up for free"),
765
+ ('a:has-text("Sign up")', "Sign up"),
766
+ ('button:has-text("Sign up")', "Sign up"),
767
+ ('a:has-text("注册")', "注册"),
768
+ ('button:has-text("注册")', "注册"),
769
+ ('a:has-text("Log in")', "Log in"),
770
+ ('button:has-text("Log in")', "Log in"),
771
  ]:
772
  try:
773
  btn = page.locator(sel).first
774
  if btn.is_visible(timeout=1000):
775
+ logger.info("[直接注册] 点击: %s", desc)
776
  btn.click()
777
+ time.sleep(3)
778
+ # 检查邮箱输入框是否出现了
779
+ if page.locator(_email_selectors).first.is_visible(timeout=3000):
780
+ break
781
  except Exception:
782
  continue
783
  except Exception: