MCPcopy Create free account
hub / github.com/HKUDS/AutoAgent / tryToClickChallenge

Function tryToClickChallenge

autoagent/environment/browser_env.py:274–300  ·  view source on GitHub ↗
(this_page)

Source from the content-addressed store, hash-verified

272 """
273 global page
274 def tryToClickChallenge(this_page):
275 try:
276 # 尝试定位并点击验证框架中的复选框
277 frame = this_page.frame_locator("iframe[title*='challenge']")
278 if frame:
279 checkbox = frame.locator("input[type='checkbox']")
280 if checkbox.is_visible():
281 checkbox.click()
282 return True
283
284 # 尝试点击验证按钮 (同时支持中英文)
285 verify_texts = ["请完成以下操作,验证您是真人。", "Verify you are human by completing the action below."]
286 for text in verify_texts:
287 verify_button = this_page.get_by_text(text)
288 if verify_button.is_visible():
289 verify_button.click()
290 return True
291
292 # 尝试点击任何可见的验证按钮
293 challenge_buttons = this_page.locator("button[class*='challenge']")
294 if challenge_buttons.count() > 0:
295 challenge_buttons.first.click()
296 return True
297
298 except Exception as e:
299 print(f"尝试点击验证失败: {str(e)}")
300 return False
301
302 check_count = 1
303 max_attempts = 6

Callers 1

_checkMeetChallengeFunction · 0.85

Calls 1

countMethod · 0.80

Tested by

no test coverage detected