package com.ghost.temple.driver; import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; import org.openqa.selenium.firefox.FirefoxProfile; import java.io.File; import java.nio.file.Paths; public class DriverManager { private static WebDriver driver; public static void initDriver() { if (driver == null) { try { // Set a local cache folder for downloaded drivers String cachePath = Paths.get(System.getProperty("user.dir"), "drivers-cache").toString(); WebDriverManager.firefoxdriver() .cachePath(cachePath) // cache folder inside project .avoidBrowserDetection() // skip local browser version check .setup(); } catch (Exception e) { System.err.println("[WARN] WebDriverManager failed to setup driver: " + e.getMessage()); // Fallback to manual driver path if cached or downloaded driver is unavailable System.setProperty("webdriver.gecko.driver", "/home/arul/solo-level-app-automation/geckodriver"); } // Firefox binary path String firefoxBinaryPath = "/home/arul/solo-level-app-automation/firefox/firefox"; // Firefox profile path String profilePath = "/home/arul/solo-level-app-automation/.mozilla/firefox/b4xl9fej.default-release"; FirefoxProfile profile = new FirefoxProfile(new File(profilePath)); FirefoxOptions options = new FirefoxOptions(); options.setBinary(firefoxBinaryPath); options.setProfile(profile); // Add kiosk mode argument for fullscreen options.addArguments("--kiosk"); driver = new FirefoxDriver(options); // Remove maximize(), kiosk mode handles fullscreen System.out.println("Launched Firefox in kiosk mode with real profile 😎"); } } public static WebDriver getDriver() { return driver; } public static void quitDriver() { if (driver != null) { driver.quit(); driver = null; } } }