Class MobileSessionStateManager
java.lang.Object
com.shaft.gui.element.internal.MobileSessionStateManager
Saves and restores Appium session capabilities and mobile app-state snapshots for one WebDriver session.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionstatic voidloadAppState(org.openqa.selenium.WebDriver driver, String filePath) Restores what is restorable of a previously saved mobile app-state snapshot on a live session: re-activates the app, switches context, and rotates the device when the corresponding capability is supported by the active driver.static org.openqa.selenium.MutableCapabilitiesloadCapabilities(String filePath) Loads previously saved Appium session capabilities from a JSON file.static voidsaveAppState(org.openqa.selenium.WebDriver driver, String filePath) Saves a snapshot of the current mobile app state (active app, context, orientation, window size) to a JSON file.static voidsaveCapabilities(org.openqa.selenium.WebDriver driver, String filePath) Saves the active Appium session capabilities to a JSON file.
-
Method Details
-
saveCapabilities
Saves the active Appium session capabilities to a JSON file.- Parameters:
driver- active WebDriver (must be a RemoteWebDriver/Appium session)filePath- target JSON file
-
loadCapabilities
Loads previously saved Appium session capabilities from a JSON file.This is a static method because capabilities must be known before a driver session exists. Example:
MutableCapabilities capabilities = MobileSessionStateManager.loadCapabilities("target/mobile-session-cache/device.json"); DriverFactory.getHelper(DriverFactory.DriverType.APPIUM_MOBILE_NATIVE, capabilities);- Parameters:
filePath- source JSON file- Returns:
- capabilities restored from the file
-
saveAppState
Saves a snapshot of the current mobile app state (active app, context, orientation, window size) to a JSON file.- Parameters:
driver- active WebDriverfilePath- target JSON file
-
loadAppState
Restores what is restorable of a previously saved mobile app-state snapshot on a live session: re-activates the app, switches context, and rotates the device when the corresponding capability is supported by the active driver. Unsupported restore steps are skipped silently.- Parameters:
driver- active WebDriverfilePath- source JSON file
-