-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfig.py
67 lines (52 loc) · 1.69 KB
/
config.py
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
from functools import lru_cache
from pydantic import BaseModel, BaseSettings, Field
from utils.webdriver.factory.browser import Browser
class DriverConfig(BaseSettings):
browser: Browser = Field(default=Browser.CHROME, env="BROWSER")
remote_url: str = Field(default="", env="REMOTE_URL")
wait_time: int = 10
page_load_wait_time: int = 0
options: list[str] = [
"ignore-certificate-errors",
"--no-sandbox",
"disable-infobars",
'--headless',
'--disable-extensions',
'--disable-gpu'
]
capabilities: dict[str, str] = {}
experimental_options: list[dict] | None = None
seleniumwire_options: dict = {}
extension_paths: list[str] | None = None
webdriver_kwargs: dict | None = None
version: str | None
local_path: str = ""
class Config:
env_file = '.env'
env_file_encoding = 'utf-8'
class LoggingConfig(BaseSettings):
log_level: str = "INFO"
screenshots_on: bool = Field(default=True, env="SCREENSHOTS_ON")
screenshots_dir: str = Field(
default='./screenshots', env="SCREENSHOTS_DIR"
)
class Config:
env_file = '.env'
env_file_encoding = 'utf-8'
class ViewportConfig(BaseModel):
maximize: bool = True
width: int = 1440
height: int = 900
orientation: str = "portrait"
class UIConfig(BaseSettings):
base_url: str = Field(env="BASE_URL")
driver: DriverConfig = DriverConfig()
logging: LoggingConfig = LoggingConfig()
viewport: ViewportConfig = ViewportConfig()
custom: dict = {}
class Config:
env_file = '.env'
env_file_encoding = 'utf-8'
@lru_cache()
def get_ui_config() -> UIConfig:
return UIConfig()