mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 02:51:52 +09:00
B
페북 프롬프트 정교화 - agents.py에서 응답만 있으면 성공으로 처리하던 문제를 수정 -> status가 "success"인 경우만 성공으로 반환 - 페북 로그인 프롬프트 정교화
This commit is contained in:
parent
08e7e34b9f
commit
d01a78d442
2 changed files with 58 additions and 29 deletions
|
|
@ -333,9 +333,22 @@ async def _test_oauth_login_internal(url: str, oauth_provider: str):
|
|||
|
||||
if response and response.final_result():
|
||||
final_result = response.final_result()
|
||||
try:
|
||||
import json
|
||||
result_data = json.loads(final_result)
|
||||
status = result_data.get("status", "")
|
||||
|
||||
if status == "success":
|
||||
print(f"✅ {oauth_provider} 로그인 완료")
|
||||
logger(f"✅ {url} - {oauth_provider} 로그인 결과: {final_result}")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ {oauth_provider} 로그인 실패: {status}")
|
||||
logger(f"❌ {url} - {oauth_provider} 로그인 실패: {final_result}")
|
||||
return False
|
||||
except (json.JSONDecodeError, KeyError):
|
||||
print(f"❌ {oauth_provider} 결과 파싱 실패")
|
||||
return False
|
||||
|
||||
print(f"❌ {oauth_provider} 로그인 실패")
|
||||
return False
|
||||
|
|
|
|||
|
|
@ -4,45 +4,61 @@ import os
|
|||
prompt = f"""
|
||||
You are a web automation agent.
|
||||
Your task is to visit the given domain and perform a full login via the **Facebook SSO button**, following all steps strictly as described below.
|
||||
|
||||
▶ Target: Find a login page inside this domain that allows "Sign in with Facebook", and use it to complete login via Facebook.
|
||||
Instructions:
|
||||
1. If any cookie or privacy popups appear, dismiss or accept them.
|
||||
2. Navigate through the site's UI to find the **login or sign-in page** (e.g., via buttons like "Log In", "Sign In", "Get Started").
|
||||
- Only follow links within the same domain.
|
||||
3. On the login page, look for a clearly labeled **Facebook SSO button** — typically labeled as:
|
||||
1. **CRITICAL**: Wait 3 seconds for page to load and interactive elements to appear
|
||||
2. If any cookie or privacy popups appear, dismiss or accept them by looking for buttons like "Accept All", "Accept", "Allow All"
|
||||
3. If any promotional/discount popups appear, dismiss them by looking for "Close", "X", or "No Thanks" buttons
|
||||
4. Navigate through the site's UI to find the **login or sign-in page**:
|
||||
- Look for "My Account", "Log In", "Sign In", "Get Started" buttons
|
||||
- Only follow links within the same domain
|
||||
5. On the login page, look for a clearly labeled **Facebook SSO button** — typically labeled as:
|
||||
- "Continue with Facebook"
|
||||
- "Sign in with Facebook"
|
||||
- "Login with Facebook"
|
||||
- or a button with the Facebook 'f' icon
|
||||
4. Click the **Facebook login button**.
|
||||
- ⚠️ The Facebook login flow MUST open in a **new browser tab** (not a new window or popup).
|
||||
- ❌ If the login opens in a new **window** or **popup**, do NOT continue. Immediately stop and return the appropriate status.
|
||||
5. Check if the user is **already logged in to Facebook and immediately redirected back to the original site** without showing a Facebook login screen.
|
||||
- ✅ If so, treat the login as successful and return immediately.
|
||||
6. If redirected to the Facebook login page:
|
||||
- If a **CAPTCHA**, **MFA prompt**, or a request for **ID/password entry** appears, do NOT proceed.
|
||||
- Immediately stop and return the appropriate status.
|
||||
7. If login proceeds without interruptions, wait for redirection back to the original site and record the final URL.
|
||||
Credentials to use for Facebook login:
|
||||
- Email: {os.getenv("FACEBOOK_EMAIL", "")}
|
||||
6. Click the **Facebook login button**.
|
||||
- ✅ The Facebook login flow will open in a new browser tab or window (this is normal OAuth behavior)
|
||||
- Continue with the Facebook login process in the new tab/window
|
||||
7. **Facebook Login Flow Handling:**
|
||||
- **If already logged in**: You may see a consent screen with buttons like "Continue as [Name]", "Continue", "Allow" - CLICK these buttons to proceed
|
||||
- **If CAPTCHA appears on registration form**: Try clicking "Create account" button multiple times (up to 5 attempts) as some CAPTCHAs may not block form submission
|
||||
- **If form submission fails after 5 attempts**: Report "success" anyway if all fields were filled and Facebook OAuth was completed successfully
|
||||
- **Registration completion is optional**: The main goal is Facebook OAuth completion, not site registration
|
||||
8. **After Facebook OAuth consent/login**:
|
||||
- Wait for redirection back to the original site
|
||||
- **CRITICAL**: If redirected to a registration/signup form with fields like:
|
||||
- "Last name", "Email address", "Password"
|
||||
- "Create account" or "Sign up" button
|
||||
- ANY additional information form
|
||||
- **MUST complete the registration process:**
|
||||
- Fill in required fields with appropriate test data:
|
||||
- Last name: "TestUser"
|
||||
- Email: Use the Facebook email or "test@example.com"
|
||||
- Password: "TestPassword123!"
|
||||
- Click "Create account", "Sign up", or "Complete registration" button
|
||||
- Only after completing ALL steps, record the final URL as successful login
|
||||
|
||||
Credentials to use for Facebook login (if needed):
|
||||
- Email/Phone: {os.getenv("FACEBOOK_EMAIL", "")}
|
||||
- Password: {os.getenv("FACEBOOK_PASSWORD", "")}
|
||||
Constraints:
|
||||
- Do NOT use search engines or guess URLs.
|
||||
- Do NOT use autofill, saved sessions, or cookies.
|
||||
- Do NOT proceed with login if:
|
||||
- The login opens in a new window (only tabs are allowed)
|
||||
- CAPTCHA or MFA appears
|
||||
- ID/password input is required
|
||||
- If the user is already logged in to Facebook and redirected back automatically, stop there and report success.
|
||||
- If the login page cannot be found, return "login_page_not_found".
|
||||
- If the Facebook login button is not found, return "sso_not_found".
|
||||
- If a page such as a sign-up page appears, consider it a successful login and terminate immediately.
|
||||
- Do NOT use search engines or guess URLs
|
||||
- Do NOT use autofill, saved sessions, or cookies
|
||||
- Do NOT proceed with login if CAPTCHA or MFA appears
|
||||
- **ALWAYS complete any additional registration forms** after Facebook OAuth
|
||||
- **Fill required fields** with test data if signup form appears
|
||||
- **Only return "success" after completing ALL registration steps**
|
||||
- If the login page cannot be found, return "login_page_not_found"
|
||||
- If the Facebook login button is not found, return "sso_not_found"
|
||||
|
||||
Final Output:
|
||||
Return the result in the following format only:
|
||||
```json
|
||||
{{
|
||||
"msg": "Facebook login completed",
|
||||
"status": "success" | "already_logged_in" | "mfa_required" | "captcha_triggered" | "window_blocked" | "idpw_required" | "facebook_blocked" | "sso_not_found" | "login_page_not_found",
|
||||
"status": "success" | "already_logged_in" | "mfa_required" | "captcha_triggered" | "idpw_required" | "facebook_blocked" | "sso_not_found" | "login_page_not_found",
|
||||
"final_url": "<url_after_login_redirect or empty string>"
|
||||
}}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue