Package com.codeborne.selenide
Class OpenOptions
java.lang.Object
com.codeborne.selenide.OpenOptions
Options for opening a page:
SelenideDriver.open(String, OpenOptions).
Allows skipping the login in tests: log in once, save the browser state to a file, and restore it in other tests.
open("/dashboard", withBrowserState("build/auth.json")
.loggedInIf(() -> $("#logout").is(visible, Duration.ofSeconds(2)))
.orLogin(() -> login("bob", "secret")));
- Since:
- 7.19.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionloggedInIf(BooleanSupplier loggedInCheck) Check if user is logged in.Log in if the file doesn't exist yet, or if the saved state is not valid anymore (as reported byloggedInIf(BooleanSupplier)).toString()static OpenOptionswithBrowserState(BrowserState browserState) Restore the given browser state before opening the page.static OpenOptionswithBrowserState(String file) Restore browser state from the given file (in JSON format) before opening the page.static OpenOptionswithBrowserState(Path file) Restore browser state from the given file (in JSON format) before opening the page.
-
Method Details
-
withBrowserState
Restore browser state from the given file (in JSON format) before opening the page. The file is not read immediately, but only when the page is being opened.- See Also:
-
withBrowserState
Restore browser state from the given file (in JSON format) before opening the page. The file is not read immediately, but only when the page is being opened.- See Also:
-
withBrowserState
Restore the given browser state before opening the page. -
loggedInIf
Check if user is logged in. Used together withorLogin(Runnable).- Parameters:
loggedInCheck- returns true if user is logged in (after restoring the state and opening the page)
-
orLogin
Log in if the file doesn't exist yet, or if the saved state is not valid anymore (as reported byloggedInIf(BooleanSupplier)). After logging in, the browser state is saved to the file.- Parameters:
login- code that logs user in (opens login page, enters credentials etc.)
-
toString
-