Refined Driver Manager Code to setup Kiosk Mode in both create-quest and solo-level

This commit is contained in:
arul 2025-08-11 23:40:41 +05:30
parent ae3e1ee04d
commit f760d8de22
24 changed files with 31 additions and 258 deletions

1
firefox/lock Symbolic link
View File

@ -0,0 +1 @@
10.0.2.15:+1518304

View File

@ -1,49 +1,19 @@
package com.ghost.temple;
import com.ghost.temple.driver.DriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import java.io.File;
import java.util.Scanner;
public class BrowserLauncher {
private static WebDriver driver;
private static final String APP_URL = "http://192.168.31.73:3000/";
public static void main(String[] args) {
// IMPORTANT: Remove WebDriverManager setup here if you already manage drivers elsewhere
// WebDriverManager.firefoxdriver().setup(); // uncomment if you want dynamic driver management
String projectDir = System.getProperty("user.dir");
// Paths customize if your automation project has different structure
String firefoxBinaryPath = projectDir + "/firefox/firefox";
String profilePath = projectDir + "/.mozilla/firefox/b4xl9fej.default-release";
File firefoxBinary = new File(firefoxBinaryPath);
if (!firefoxBinary.exists() || !firefoxBinary.canExecute()) {
System.err.println("❌ Firefox binary missing or not executable at: " + firefoxBinaryPath);
System.exit(1);
}
File profileDir = new File(profilePath);
if (!profileDir.exists() || !profileDir.isDirectory()) {
System.err.println("❌ Firefox profile directory missing or invalid at: " + profilePath);
System.exit(1);
}
FirefoxProfile profile = new FirefoxProfile(profileDir);
FirefoxOptions options = new FirefoxOptions();
options.setBinary(new FirefoxBinary(firefoxBinary));
options.setProfile(profile);
driver = new FirefoxDriver(options);
driver.manage().window().maximize();
// Use DriverManager to init driver (which already uses kiosk mode)
DriverManager.initDriver();
driver = DriverManager.getDriver();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
System.out.println("\n⚠ JVM Shutdown detected. Saving data before exit...");
@ -54,13 +24,13 @@ public class BrowserLauncher {
StorageManager.loadStorage(driver, APP_URL);
CookieManager.loadCookies(driver, APP_URL);
System.out.println("🔥 Browser launched with persisted cookies and storage!");
System.out.println("🔥 Browser launched with persisted cookies and storage in kiosk mode!");
Scanner scanner = new Scanner(System.in);
String input = "";
while (!input.equalsIgnoreCase("save")) {
speakPrompt("Please type save and press Enter to save your work before closing the browser.");
speakPrompt("Please type save and press Enter to save your work before closing the System.");
System.out.print("> ");
input = scanner.nextLine().trim();
@ -78,10 +48,7 @@ public class BrowserLauncher {
} catch (Exception e) {
e.printStackTrace();
} finally {
if (driver != null) {
driver.quit();
driver = null;
}
DriverManager.quitDriver();
}
}
@ -111,3 +78,4 @@ public class BrowserLauncher {
}
}
}

View File

@ -26,7 +26,6 @@ public class DriverManager {
} 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
// Change this path to your manually downloaded geckodriver executable
System.setProperty("webdriver.gecko.driver",
"/home/arul/solo-level-app-automation/geckodriver");
}
@ -42,9 +41,13 @@ public class DriverManager {
options.setBinary(firefoxBinaryPath);
options.setProfile(profile);
// Add kiosk mode argument for fullscreen
options.addArguments("--kiosk");
driver = new FirefoxDriver(options);
driver.manage().window().maximize();
System.out.println("Launched Firefox with real profile 😎");
// Remove maximize(), kiosk mode handles fullscreen
System.out.println("Launched Firefox in kiosk mode with real profile 😎");
}
}

View File

@ -6,6 +6,8 @@ import com.ghost.temple.driver.DriverManager;
import io.cucumber.java.After;
import io.cucumber.java.Before;
import org.openqa.selenium.WebDriver;
public class Hooks {
private static final String APP_URL = "http://192.168.31.73:3000/";
@ -13,22 +15,25 @@ public class Hooks {
@Before
public void setUp() {
DriverManager.initDriver();
StorageManager.loadStorage(DriverManager.getDriver(), APP_URL); // Load local/session storage
CookieManager.loadCookies(DriverManager.getDriver(), APP_URL); // Load cookies
}
WebDriver driver = DriverManager.getDriver();
StorageManager.loadStorage(driver, APP_URL);
CookieManager.loadCookies(driver, APP_URL);
// No need to send F11 since kiosk mode opens fullscreen
}
@After
public void tearDown() {
try {
// Wait for 15 seconds (15000 milliseconds)
try {
Thread.sleep(15000);
} catch (InterruptedException e) {
e.printStackTrace();
}
StorageManager.saveStorage(DriverManager.getDriver()); // Save local/session storage
CookieManager.saveCookies(DriverManager.getDriver()); // Save cookies
DriverManager.quitDriver(); // Then quit driver
}
}
WebDriver driver = DriverManager.getDriver();
StorageManager.saveStorage(driver);
CookieManager.saveCookies(driver);
DriverManager.quitDriver();
}
}

View File

@ -1 +1 @@
{"localStorage":{"soloLevelUpUserStats":"{\"name\":\"Arul\",\"level\":1,\"exp\":0,\"expToNextLevel\":100,\"job\":null,\"title\":null,\"hp\":100,\"maxHp\":100,\"mp\":10,\"maxMp\":10,\"fatigue\":0,\"gold\":0,\"stats\":{\"str\":10,\"agi\":10,\"per\":10,\"int\":10,\"vit\":10},\"statPoints\":0,\"equipment\":[],\"quests\":[],\"completedQuests\":[],\"inventory\":[{\"id\":\"item-health-potion\",\"name\":\"Health Potion\",\"type\":\"Consumable\",\"rarity\":\"Common\",\"description\":\"Restores 100 HP when consumed.\",\"quantity\":3},{\"id\":\"item-mana-potion\",\"name\":\"Mana Potion\",\"type\":\"Consumable\",\"rarity\":\"Common\",\"description\":\"Restores 50 MP when consumed.\",\"quantity\":2}]}"},"sessionStorage":{}}
{"localStorage":{"soloLevelUpUserStats":"{\"name\":\"Arul\",\"level\":1,\"exp\":0,\"expToNextLevel\":100,\"job\":null,\"title\":null,\"hp\":100,\"maxHp\":100,\"mp\":10,\"maxMp\":10,\"fatigue\":0,\"gold\":0,\"stats\":{\"str\":10,\"agi\":10,\"per\":10,\"int\":10,\"vit\":10},\"statPoints\":0,\"equipment\":[],\"quests\":[{\"title\":\"Offgrid Hermit - Disconnect from Internet\",\"description\":\"ghostTemple system forces user by disabling internet by default in the computer to go offgrid. Equiped with self designed /etc/host based porn blocker. It still provides user option to enable the internet at boot. asking user to enter password. to make user realize that their decision is conscious.\",\"reward\":\"1 Gold, +2 Strength, +4 Perception, +2 Intelligence, +1 Vitality\",\"difficulty\":\"A\",\"priority\":\"High\",\"expiry\":\"Daily\",\"expReward\":15,\"statPointsReward\":1,\"goldReward\":1,\"statRewards\":{\"str\":2,\"agi\":0,\"per\":4,\"int\":2,\"vit\":1},\"itemRewards\":[],\"id\":\"88f5eb51-3e1b-483c-91fd-158f727fd43c\",\"active\":true,\"completed\":false,\"progress\":0,\"isCustom\":true,\"createdAt\":1754934091968},{\"title\":\"The Refiner - Appearance Leveling\",\"description\":\"Focusing on Skin health, Hair health, preventing Hair loss, Preventing Fat gain. Focused on Weight Loss and over all Hygiene the way we look. To Attract people and be charismatic.\",\"reward\":\"2 Gold, +2 Strength, +3 Agility, +2 Vitality\",\"difficulty\":\"C\",\"priority\":\"High\",\"expiry\":\"Daily\",\"expReward\":15,\"statPointsReward\":2,\"goldReward\":2,\"statRewards\":{\"str\":2,\"agi\":3,\"per\":0,\"int\":0,\"vit\":2},\"itemRewards\":[],\"id\":\"35655c25-099e-44dc-8f6c-9a6a109c76ab\",\"active\":true,\"completed\":false,\"progress\":0,\"isCustom\":true,\"createdAt\":1754934099662},{\"title\":\"King of Deception - Leveling up Art of Attraction\",\"description\":\"Focused on building a solid character. that is strong.. Talented, Attract people and seductive at same time. Manipulative in good way. Positive Manipulation by doing a good job on something we do and gaining trust among other people.\",\"reward\":\"2 Gold, +1 Strength, +3 Perception, +3 Intelligence, +2 Vitality\",\"difficulty\":\"B\",\"priority\":\"Medium\",\"expiry\":\"Daily\",\"expReward\":10,\"statPointsReward\":2,\"goldReward\":2,\"statRewards\":{\"str\":1,\"agi\":0,\"per\":3,\"int\":3,\"vit\":2},\"itemRewards\":[],\"id\":\"3c331c3e-42b9-4a7e-86a8-e03113906a21\",\"active\":true,\"completed\":false,\"progress\":0,\"isCustom\":true,\"createdAt\":1754934108102},{\"title\":\"The Architect of Himself - Leveling up strength both physically and mentally\",\"description\":\"1. Exercise everyday Morning 1 hr (Cardio + strength) 2. Gain Knowledge on New concept or Technology, Read books. 3. Train Martial arts - Armed or Unarmed combat styles. Focus on Leveling up your Intellect, your Strength, Your Martial arts skill and your Aesthetics eventually.\",\"reward\":\"3 Gold, +3 Strength, +5 Agility, +3 Perception, +3 Intelligence, +3 Vitality\",\"difficulty\":\"S\",\"priority\":\"High\",\"expiry\":\"Daily\",\"expReward\":30,\"statPointsReward\":3,\"goldReward\":3,\"statRewards\":{\"str\":3,\"agi\":5,\"per\":3,\"int\":3,\"vit\":3},\"itemRewards\":[],\"id\":\"e65a09eb-ceec-4d85-98f0-469d69cb2b28\",\"active\":true,\"completed\":false,\"progress\":0,\"isCustom\":true,\"createdAt\":1754934117510},{\"title\":\"The Phoenix - Rise from Ashes\",\"description\":\"Keep Moving Forward, No matter what. No matter how much pain you face. you can do take breaks to learn from failures. But never quit . Never Settle. Accept your Pain. see it as a part of life. both physical and Mental Pain. If you can cure it you can cure them. but if you can't never use them as an excuse to be Lower. Always improve from pain and be strong if possible. the Key idea is not to stop at any cost and keep moving forward. Not to embrace pain or romanticize it.\",\"reward\":\"2 Gold, +2 Strength, +2 Agility, +2 Intelligence, +2 Vitality\",\"difficulty\":\"S\",\"priority\":\"High\",\"expiry\":\"Daily\",\"expReward\":30,\"statPointsReward\":2,\"goldReward\":2,\"statRewards\":{\"str\":2,\"agi\":2,\"per\":0,\"int\":2,\"vit\":2},\"itemRewards\":[],\"id\":\"18156b0f-de37-43ef-a5b6-3530b3e11abf\",\"active\":true,\"completed\":false,\"progress\":0,\"isCustom\":true,\"createdAt\":1754934128774}],\"completedQuests\":[],\"inventory\":[{\"id\":\"item-health-potion\",\"name\":\"Health Potion\",\"type\":\"Consumable\",\"rarity\":\"Common\",\"description\":\"Restores 100 HP when consumed.\",\"quantity\":3},{\"id\":\"item-mana-potion\",\"name\":\"Mana Potion\",\"type\":\"Consumable\",\"rarity\":\"Common\",\"description\":\"Restores 50 MP when consumed.\",\"quantity\":2}]}"},"sessionStorage":{}}

View File

@ -1 +0,0 @@
,arul,ghostTemple,09.08.2025 12:11,file:///home/arul/.config/libreoffice/4;

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
com/ghost/temple/stepdefs/HomePageStepDefs.class
com/ghost/temple/pages/Quests.class
com/ghost/temple/BaseTest.class
com/ghost/temple/TestRunner.class
com/ghost/temple/AppTest.class
com/ghost/temple/pages/HomePage.class
com/ghost/temple/stepdefs/QuestsStepDefs.class

View File

@ -1,7 +0,0 @@
/home/arul/solo-level-app-automation/src/test/java/com/ghost/temple/stepdefs/HomePageStepDefs.java
/home/arul/solo-level-app-automation/src/test/java/com/ghost/temple/AppTest.java
/home/arul/solo-level-app-automation/src/test/java/com/ghost/temple/BaseTest.java
/home/arul/solo-level-app-automation/src/test/java/com/ghost/temple/pages/HomePage.java
/home/arul/solo-level-app-automation/src/test/java/com/ghost/temple/TestRunner.java
/home/arul/solo-level-app-automation/src/test/java/com/ghost/temple/pages/Quests.java
/home/arul/solo-level-app-automation/src/test/java/com/ghost/temple/stepdefs/QuestsStepDefs.java

View File

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="1" failures="0" name="com.ghost.temple.AppTest" time="0.005" errors="0" skipped="0">
<properties>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="java.vm.version" value="17.0.15+6-Debian-1deb12u1"/>
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-17-openjdk-amd64/lib"/>
<property name="maven.multiModuleProjectDirectory" value="/home/arul/solo-level-app-automation"/>
<property name="java.vm.vendor" value="Debian"/>
<property name="java.vendor.url" value="https://tracker.debian.org/openjdk-17"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="path.separator" value=":"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="user.country" value="IN"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="/home/arul/solo-level-app-automation"/>
<property name="java.vm.compressedOopsMode" value="32-bit"/>
<property name="java.runtime.version" value="17.0.15+6-Debian-1deb12u1"/>
<property name="os.arch" value="amd64"/>
<property name="java.io.tmpdir" value="/tmp"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="os.name" value="Linux"/>
<property name="classworlds.conf" value="/usr/share/maven/bin/m2.conf"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.library.path" value="/tmp/.mount_eDEX-UzEzEGG/usr/lib::/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/>
<property name="maven.conf" value="/usr/share/maven/conf"/>
<property name="jdk.debug" value="release"/>
<property name="java.class.version" value="61.0"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="os.version" value="6.5.0-0.deb12.4-amd64"/>
<property name="library.jansi.path" value="/usr/share/maven/lib/jansi-native"/>
<property name="user.home" value="/home/arul"/>
<property name="user.timezone" value="Asia/Kolkata"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.specification.version" value="17"/>
<property name="user.name" value="arul"/>
<property name="java.class.path" value="/usr/share/maven/boot/plexus-classworlds-2.x.jar"/>
<property name="java.vm.specification.version" value="17"/>
<property name="sun.arch.data.model" value="64"/>
<property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher test"/>
<property name="java.home" value="/usr/lib/jvm/java-17-openjdk-amd64"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="java.version" value="17.0.15"/>
<property name="native.encoding" value="UTF-8"/>
<property name="java.vendor" value="Debian"/>
<property name="sun.stderr.encoding" value="UTF-8"/>
<property name="java.specification.maintenance.version" value="1"/>
<property name="maven.home" value="/usr/share/maven"/>
<property name="file.separator" value="/"/>
<property name="java.version.date" value="2025-04-15"/>
<property name="java.vendor.url.bug" value="https://bugs.debian.org/openjdk-17"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.stdout.encoding" value="UTF-8"/>
</properties>
<testcase classname="com.ghost.temple.AppTest" name="basicTest" time="0.005"/>
</testsuite>

View File

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite tests="1" failures="0" name="com.ghost.temple.TestRunner" time="71.286" errors="0" skipped="0">
<properties>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="java.vm.version" value="17.0.15+6-Debian-1deb12u1"/>
<property name="sun.boot.library.path" value="/usr/lib/jvm/java-17-openjdk-amd64/lib"/>
<property name="maven.multiModuleProjectDirectory" value="/home/arul/solo-level-app-automation"/>
<property name="java.vm.vendor" value="Debian"/>
<property name="java.vendor.url" value="https://tracker.debian.org/openjdk-17"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="path.separator" value=":"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="user.country" value="IN"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="/home/arul/solo-level-app-automation"/>
<property name="java.vm.compressedOopsMode" value="32-bit"/>
<property name="java.runtime.version" value="17.0.15+6-Debian-1deb12u1"/>
<property name="os.arch" value="amd64"/>
<property name="java.io.tmpdir" value="/tmp"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="os.name" value="Linux"/>
<property name="classworlds.conf" value="/usr/share/maven/bin/m2.conf"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.library.path" value="/tmp/.mount_eDEX-UzEzEGG/usr/lib::/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib"/>
<property name="maven.conf" value="/usr/share/maven/conf"/>
<property name="jdk.debug" value="release"/>
<property name="java.class.version" value="61.0"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="os.version" value="6.5.0-0.deb12.4-amd64"/>
<property name="library.jansi.path" value="/usr/share/maven/lib/jansi-native"/>
<property name="user.home" value="/home/arul"/>
<property name="user.timezone" value="Asia/Kolkata"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.specification.version" value="17"/>
<property name="user.name" value="arul"/>
<property name="java.class.path" value="/usr/share/maven/boot/plexus-classworlds-2.x.jar"/>
<property name="java.vm.specification.version" value="17"/>
<property name="sun.arch.data.model" value="64"/>
<property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher test"/>
<property name="java.home" value="/usr/lib/jvm/java-17-openjdk-amd64"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="java.vm.info" value="mixed mode, sharing"/>
<property name="java.version" value="17.0.15"/>
<property name="native.encoding" value="UTF-8"/>
<property name="java.vendor" value="Debian"/>
<property name="sun.stderr.encoding" value="UTF-8"/>
<property name="java.specification.maintenance.version" value="1"/>
<property name="maven.home" value="/usr/share/maven"/>
<property name="file.separator" value="/"/>
<property name="java.version.date" value="2025-04-15"/>
<property name="java.vendor.url.bug" value="https://bugs.debian.org/openjdk-17"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.stdout.encoding" value="UTF-8"/>
</properties>
<testcase classname="Solo Leveling Quest Management" name="Open Solo Leveling page and click Add Quest" time="71.286"/>
</testsuite>

View File

@ -1,4 +0,0 @@
-------------------------------------------------------------------------------
Test set: com.ghost.temple.AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.012 sec

View File

@ -1,4 +0,0 @@
-------------------------------------------------------------------------------
Test set: com.ghost.temple.TestRunner
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 71.941 sec

View File

@ -1,7 +0,0 @@
Feature: Solo Leveling Quest Management
Scenario: Open Solo Leveling page and click Add Quest
Given I open the solo level page
When I click the Add Quest button
When I fill all the quests from Excel