import { chromium } from 'playwright';
const browser = await chromium.launch();
const page = await browser.newPage();
// Navigate to TreasuryDirect system
await page.goto('https://treasurydirect.gov/forms/');
// Start new account authorization form
await page.click('[data-testid="manage-account"]');
await page.click('[data-testid="account-authorization"]');
await page.selectOption('[name="form_type"]', 'fs_5444');
// Account holder information
await page.fill('[name="account_holder_name"]', 'Margaret Elizabeth Wilson');
await page.fill('[name="ssn"]', '123-45-6789');
await page.fill('[name="account_number"]', 'TD-987654321');
await page.fill('[name="date_of_birth"]', '06/12/1968');
// Contact information
await page.fill('[name="address"]', '456 Financial Plaza, Suite 200');
await page.fill('[name="city"]', 'Charlotte');
await page.selectOption('[name="state"]', 'NC');
await page.fill('[name="zip"]', '28202');
await page.fill('[name="phone"]', '704-555-0156');
await page.fill('[name="email"]', 'mwilson@email.com');
// Type of authorization
await page.selectOption('[name="authorization_type"]', 'account_manager');
await page.check('[name="full_transaction_authority"]');
// Authorized individual information
await page.fill('[name="authorized_name"]', 'Robert James Wilson');
await page.fill('[name="authorized_ssn"]', '987-65-4321');
await page.fill('[name="authorized_relationship"]', 'Spouse');
await page.fill('[name="authorized_date_of_birth"]', '03/18/1965');
// Authorized person contact information
await page.fill('[name="authorized_address"]', '456 Financial Plaza, Suite 200');
await page.fill('[name="authorized_city"]', 'Charlotte');
await page.selectOption('[name="authorized_state"]', 'NC');
await page.fill('[name="authorized_zip"]', '28202');
await page.fill('[name="authorized_phone"]', '704-555-0157');
await page.fill('[name="authorized_email"]', 'rwilson@email.com');
// Authorization scope
await page.check('[name="purchase_securities"]');
await page.check('[name="redeem_securities"]');
await page.check('[name="reinvest_securities"]');
await page.check('[name="change_registration"]');
await page.check('[name="view_account_information"]');
await page.check('[name="update_banking_information"]');
// Securities types covered
await page.check('[name="savings_bonds"]');
await page.check('[name="treasury_bills"]');
await page.check('[name="treasury_notes"]');
await page.check('[name="treasury_bonds"]');
await page.check('[name="tips"]');
// Transaction limits (if applicable)
await page.check('[name="set_transaction_limits"]');
await page.fill('[name="single_transaction_limit"]', '50000');
await page.fill('[name="monthly_limit"]', '200000');
await page.fill('[name="annual_limit"]', '1000000');
// Effective dates
await page.fill('[name="authorization_start_date"]', '03/01/2025');
await page.selectOption('[name="authorization_duration"]', 'indefinite');
// Special conditions or restrictions
await page.fill('[name="special_instructions"]', 'Authorization valid for all routine transactions. Redemptions over $100,000 require phone confirmation with primary account holder.');
// Secondary authorized person (if applicable)
await page.check('[name="add_secondary_authorized"]');
await page.fill('[name="secondary_name"]', 'Jennifer Marie Wilson');
await page.fill('[name="secondary_ssn"]', '234-56-7890');
await page.fill('[name="secondary_relationship"]', 'Daughter');
await page.selectOption('[name="secondary_authority_level"]', 'view_only');
// Notification preferences
await page.check('[name="notify_primary_on_transactions"]');
await page.check('[name="email_confirmations"]');
await page.check('[name="monthly_statements"]');
// Banking information for authorized transactions
await page.fill('[name="linked_bank_name"]', 'Bank of America');
await page.fill('[name="routing_number"]', '053000196');
await page.fill('[name="account_number"]', '123456789012');
await page.selectOption('[name="account_type"]', 'checking');
// Security questions for authorized person
await page.fill('[name="security_question_1"]', 'What is your mother\'s maiden name?');
await page.fill('[name="security_answer_1"]', process.env.SECURITY_ANSWER_1);
await page.fill('[name="security_question_2"]', 'What city were you born in?');
await page.fill('[name="security_answer_2"]', process.env.SECURITY_ANSWER_2);
// Identity verification documents
await page.click('[data-testid="upload-id-primary"]');
await page.setInputFiles('[name="primary_identification"]', './documents/primary_drivers_license.pdf');
await page.click('[data-testid="upload-id-authorized"]');
await page.setInputFiles('[name="authorized_identification"]', './documents/authorized_drivers_license.pdf');
await page.click('[data-testid="upload-proof-relationship"]');
await page.setInputFiles('[name="relationship_proof"]', './documents/marriage_certificate.pdf');
// Medallion signature guarantee (if required)
await page.check('[name="medallion_guarantee_required"]');
await page.fill('[name="medallion_institution"]', 'Wells Fargo Bank');
await page.fill('[name="medallion_stamp_number"]', 'MSG-2025-456789');
await page.fill('[name="medallion_date"]', '02/20/2025');
// Account holder certification
await page.check('[name="certify_accuracy"]');
await page.check('[name="certify_authority"]');
await page.check('[name="authorize_treasury_verification"]');
await page.check('[name="acknowledge_liability"]');
await page.check('[name="understand_revocation_rights"]');
// Account holder signature
await page.fill('[name="account_holder_signature"]', 'Margaret Elizabeth Wilson');
await page.fill('[name="signature_date"]', '02/20/2025');
// Authorized person acceptance
await page.check('[name="authorized_accepts_responsibility"]');
await page.check('[name="authorized_agrees_to_terms"]');
await page.fill('[name="authorized_signature"]', 'Robert James Wilson');
await page.fill('[name="authorized_signature_date"]', '02/20/2025');
// Witness information (if required)
await page.fill('[name="witness_name"]', 'Sarah Financial Advisor');
await page.fill('[name="witness_title"]', 'Certified Financial Planner');
await page.fill('[name="witness_signature"]', 'Sarah Financial Advisor');
await page.fill('[name="witness_date"]', '02/20/2025');
await page.click('[data-testid="submit-authorization"]');
// Download confirmation
await page.click('[data-testid="download-confirmation"]');
await browser.close();