-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_flow_automation_no_input.py
More file actions
94 lines (76 loc) · 2.97 KB
/
test_flow_automation_no_input.py
File metadata and controls
94 lines (76 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
"""
Test script for Flow automation without interactive input
"""
import os
import time
import logging
from flow_automation import GoogleFlowAutomation
# Configure logging to debug level
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[
logging.StreamHandler(),
logging.FileHandler("test_flow_automation_no_input.log", encoding="utf-8"),
],
)
logger = logging.getLogger(__name__)
def test_automation():
"""Test the automation without interactive input"""
try:
logger.info("=== Starting Flow Automation Test ===")
# Initialize automation with your profile
bot = GoogleFlowAutomation(headless=False)
bot.setup_driver()
bot.go_to_flow()
logger.info("Flow tool opened successfully")
# Wait for page to load and any login to complete
logger.info("Waiting for page to load completely...")
time.sleep(10)
# Test prompt
test_prompt = "A serene mountain landscape with a lake at sunset"
logger.info(f"Starting generation with prompt: '{test_prompt}'")
print(f"\nGenerating: '{test_prompt}'")
# Run generation
success = bot.generate(test_prompt)
if success:
logger.info("✅ Generation completed successfully")
print("\n✅ Generation completed successfully!")
# Check downloads
downloads_dir = "downloads"
if os.path.exists(downloads_dir):
files = os.listdir(downloads_dir)
logger.debug(f"Downloads directory contains: {files}")
# Find the generated image
image_files = [
f
for f in files
if f.lower().endswith((".png", ".jpg", ".jpeg", ".webp"))
]
if image_files:
logger.info(f"Generated files found: {len(image_files)} images")
print(f"Generated images found: {len(image_files)}")
for img_file in image_files:
file_path = os.path.join(downloads_dir, img_file)
file_size = os.path.getsize(file_path)
logger.debug(f" {img_file}: {file_size} bytes")
else:
logger.warning("⚠️ No image files found in downloads directory")
print("⚠️ No image files found in downloads directory")
else:
logger.error("❌ Generation failed")
print("\n❌ Generation failed!")
# Cleanup
bot.close()
logger.info("=== Test complete ===")
except Exception as e:
logger.error(f"Test failed: {e}")
import traceback
logger.error(f"Stack trace: {traceback.format_exc()}")
print(f"\nError: {e}")
finally:
if "bot" in locals():
bot.close()
if __name__ == "__main__":
test_automation()