Skip to content

Commit d02dc96

Browse files
author
serhii.suzanskyi
committed
fixed ui execution in headless mode
1 parent 9fdd693 commit d02dc96

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

utilities/driver_factory.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@
77
from webdriver_manager.chrome import ChromeDriverManager
88
from webdriver_manager.firefox import GeckoDriverManager
99

10+
1011
class DriverFactory:
1112
@staticmethod
1213
def get_driver(browser_name):
1314
if browser_name.lower() == "chrome":
1415
options = webdriver.ChromeOptions()
15-
options.add_argument("--start-maximized") # Open in maximized mode
16+
options.add_argument("--headless=new") # Run in headless mode
1617
options.add_argument("--disable-gpu") # Disable GPU (fixes some rendering issues)
1718
options.add_argument("--no-sandbox") # Bypass OS security model (for Docker/Linux)
1819
options.add_argument("--disable-dev-shm-usage") # Prevent crashes in Docker/Linux
20+
options.add_argument("--remote-debugging-port=9222") # Avoid session issues
21+
options.add_argument("--user-data-dir=/tmp/chrome-user-data") # Unique session directory
1922
options.add_experimental_option("excludeSwitches", ["enable-automation"]) # Avoid detection
2023
options.add_experimental_option("useAutomationExtension", False) # Disable automation extension
2124

2225
return webdriver.Chrome(
2326
service=Service(ChromeDriverManager().install()), options=options
2427
)
28+
2529
elif browser_name.lower() == "firefox":
2630
return webdriver.Firefox(service=Service(GeckoDriverManager().install()))
2731
else:
28-
raise ValueError(f"Browser {browser_name} is not supported")
32+
raise ValueError(f"Browser {browser_name} is not supported")

0 commit comments

Comments
 (0)