-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser_controller.py
More file actions
118 lines (100 loc) · 2.97 KB
/
browser_controller.py
File metadata and controls
118 lines (100 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""
Browser Controller Package
A robust browser automation component for Large Action Model (LAM) systems.
Provides high-level interfaces for web browser interaction, session management,
and intelligent waiting strategies.
"""
# Import all main components
from src.core.browser_controller import BrowserController
from src.config.browser_config import BrowserConfig, ConfigManager
from src.types import (
BrowserType, WaitStrategy, ElementLocatorType,
ProxyConfig, ViewportConfig, MobileEmulation,
AuthenticationConfig, BrowserCapabilities,
SessionMetadata, NavigationResult, ElementInfo, PageInfo,
ElementLocator, Coordinates, WindowSize
)
from src.utils import (
BrowserLogger, get_logger, set_log_level,
BrowserControllerError, BrowserLaunchError, SessionError,
NavigationError, ElementNotFoundError, ElementInteractionError,
TimeoutError, AuthenticationError, ConfigurationError
)
# Package metadata
__version__ = "1.0.1"
__author__ = "LAM Project"
__description__ = "Browser Controller component for Large Action Model web automation"
__license__ = "MIT"
# Main exports
__all__ = [
# Main classes
"BrowserController",
"BrowserConfig",
"ConfigManager",
# Types and enums
"BrowserType",
"WaitStrategy",
"ElementLocatorType",
# Configuration classes
"ProxyConfig",
"ViewportConfig",
"MobileEmulation",
"AuthenticationConfig",
"BrowserCapabilities",
# Data classes
"SessionMetadata",
"NavigationResult",
"ElementInfo",
"PageInfo",
# Type aliases
"ElementLocator",
"Coordinates",
"WindowSize",
# Utilities
"BrowserLogger",
"get_logger",
"set_log_level",
# Exceptions
"BrowserControllerError",
"BrowserLaunchError",
"SessionError",
"NavigationError",
"ElementNotFoundError",
"ElementInteractionError",
"TimeoutError",
"AuthenticationError",
"ConfigurationError",
# Package info
"__version__",
"__author__",
"__description__",
"__license__",
]
# Convenience function for quick setup
def create_browser_controller(
browser_type: str = "chrome",
headless: bool = True,
window_size: tuple = (1920, 1080),
**kwargs
) -> BrowserController:
"""
Create a BrowserController with common configuration.
Args:
browser_type: Browser type ("chrome", "firefox", "edge")
headless: Run in headless mode
window_size: Browser window size as (width, height)
**kwargs: Additional configuration options
Returns:
Configured BrowserController instance
"""
config = BrowserConfig(
browser_type=BrowserType(browser_type.lower()),
headless=headless,
window_size=window_size,
**kwargs
)
return BrowserController(config)
# Package-level logger
logger = get_logger("BrowserController")
# Log package initialization
logger.info(f"Browser Controller v{__version__} initialized")