6. TESTING & DEBUGGING


6.1 FUNCTIONAL TESTING :

A. Email Alerts

1.    Replace sensitive variables with test credentials:

Python CODE :

EMAIL_ADDRESS = "test_email@gmail.com"

EMAIL_PASSWORD = "test_password"

TO_EMAIL = "recipient_email@gmail.com"

2.    Run the send_email function with various test cases:

Python CODE:

send_email(

"Test Subject",

"This is a test email.",

    screenshot_path="screenshot.png"  # Optional

)

3.    Verify:

§  Email is received in the recipient inbox.

§  Attachments (if any) are intact.

§  Subject and body contain expected content.

B. Clipboard Monitoring

1.    Copy text to the clipboard using Ctrl+C or Right-click → Copy.

2.    Check if the text is printed in the console and logged in the email alert.

3.    Debug unexpected errors:

§  Error: Clipboard cannot be accessed.

§   Solution: Check for permissions or use an alternative library like pyperclip with administrator privileges.

C. AI Tool Detection

1.    Open a test application like a browser running ChatGPT.

2.    Verify detection and email alert are triggered.

3.    Debugging:

§  Error: AI process is not detected.

§  Solution: Add more process names in the ai_tools list or confirm the correct process name using a tool like Task Manager.

D. Keylogging

1.    Press monitored keys (e.g., Tab or any other suspicious key).

2.    Check for:

§  Console message indicating key detection.

§  Email alert for the key press.

3.    Debugging:

§  Error: Key presses are not logged. Solution: Ensure the script has permission to monitor input (e.g., run as administrator).

 

E. Active Window Monitoring

1.    Switch between different applications.

2.    Verify:

§  Console logs display the correct active window name.

§  Email alerts contain the correct window details.

3.    Debugging:

§  Error: No alerts for window changes. Solution: Test using simplified versions of the win32gui and psutil integration to isolate the issue.


6.2 Debugging Common Errors

Error 1: Failed to send email

1.              Verify EMAIL_ADDRESS and EMAIL_PASSWORD.

2.              Confirm that Google App Passwords are enabled.

3.              Ensure SMTP settings are correct:

§  Host: smtp.gmail.com

§  Port: 587

4.              Log SMTP exceptions for further diagnosis.

 

 

Error 2: Clipboard access denied

 

Error 3: AI process detection failure

 

Error 4: Keylogger doesn’t detect keys

 

 

 

 

 

6.3 Integration Testing

1.    Start the script and simulate a sequence of monitored actions:

§  Clipboard change

§  AI tool usage

§  Key press

§  Active window change

2.    Ensure all actions trigger appropriate responses and email alerts.

3.    Validate:

§  Alerts are not duplicated.

§  System performance is stable during monitoring

 

6.4 Performance Testing

Optimize by reducing monitoring frequency (e.g., increase time.sleep intervals).