Package com.codeborne.selenide
Record Class BrowserState
java.lang.Object
java.lang.Record
com.codeborne.selenide.BrowserState
public record BrowserState(String origin, List<org.openqa.selenium.Cookie> cookies, Map<String,String> localStorage, Map<String,String> sessionStorage)
extends Record
State of a browser for one origin: cookies, localStorage and sessionStorage.
BrowserState state = webdriver().getBrowserState();
String json = state.toJson();
...
webdriver().restoreBrowserState(BrowserState.fromJson(json));
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList<org.openqa.selenium.Cookie>cookies()Returns the value of thecookiesrecord component.final booleanIndicates whether some other object is "equal to" this one.static BrowserStateRead browser state from a file (in JSON format), e.g.static BrowserStateRead browser state from a file (in JSON format), e.g.static BrowserStateBrowser state as JSON string (e.g.final inthashCode()Returns a hash code value for this object.Returns the value of thelocalStoragerecord component.origin()Returns the value of theoriginrecord component.Returns the value of thesessionStoragerecord component.toJson()toString()Cookie and storage values are not included: they are credentials.
-
Constructor Details
-
BrowserState
public BrowserState(String origin, List<org.openqa.selenium.Cookie> cookies, Map<String, String> localStorage, Map<String, String> sessionStorage) Creates an instance of aBrowserStaterecord class.- Parameters:
origin- the value for theoriginrecord componentcookies- the value for thecookiesrecord componentlocalStorage- the value for thelocalStoragerecord componentsessionStorage- the value for thesessionStoragerecord component
-
-
Method Details
-
fromFile
Read browser state from a file (in JSON format), e.g. previously saved byBrowserSession.saveBrowserState(Path) -
fromFile
Read browser state from a file (in JSON format), e.g. previously saved byBrowserSession.saveBrowserState(Path) -
fromJson
Browser state as JSON string (e.g. previously generated bytoJson()) -
toJson
-
toString
Cookie and storage values are not included: they are credentials. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
origin
Returns the value of theoriginrecord component.- Returns:
- the value of the
originrecord component
-
cookies
Returns the value of thecookiesrecord component.- Returns:
- the value of the
cookiesrecord component
-
localStorage
Returns the value of thelocalStoragerecord component.- Returns:
- the value of the
localStoragerecord component
-
sessionStorage
Returns the value of thesessionStoragerecord component.- Returns:
- the value of the
sessionStoragerecord component
-