Class Selenide
You start with methods open(String) for opening the tested application page and
$(String) for searching web elements.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.codeborne.selenide.SelenideElementLocates the first element matching given CSS selector (lazy evaluation)static com.codeborne.selenide.SelenideElementLocates the Nth element matching given criteria (lazy evaluation)static com.codeborne.selenide.SelenideElement$(org.openqa.selenium.By seleniumSelector) Locates the first element matching given CSS selector (lazy evaluation)static com.codeborne.selenide.SelenideElement$(org.openqa.selenium.By seleniumSelector, int index) static com.codeborne.selenide.SelenideElement$(org.openqa.selenium.WebElement webElement) Wrap standard Selenium WebElement into SelenideElement to use additional methods likeSelenideElement.should(WebElementCondition...),SelenideElement.selectOption(String, String...)etc.static com.codeborne.selenide.ElementsCollectionLocates all elements matching given CSS selector (lazy evaluation).static com.codeborne.selenide.ElementsCollection$$(Collection<? extends org.openqa.selenium.WebElement> elements) Initialize collection with Elementsstatic com.codeborne.selenide.ElementsCollection$$(org.openqa.selenium.By seleniumSelector) Locates all elements matching given CSS selector.static com.codeborne.selenide.ElementsCollectionLocates all elements matching given XPATH expression (lazy evaluation)static com.codeborne.selenide.SelenideElementLocates the first element matching given XPATH expression (lazy evaluation)static org.openqa.selenium.interactions.Actionsactions()With this method you can use Selenium Actions like described in the AdvancedUserInteractions page.static booleanatBottom()Return true if bottom of the page is reachedstatic voidback()Navigate browser back to previous pagestatic voidClear browser cookies.static voidClear browser local storage.static com.codeborne.selenide.ClipboardProvide access to system clipboard, allows get and set String content.static voidClose the browser if it's open.static voidClose the current window, quitting the browser if it's the last window currently open.static Stringconfirm()Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').static StringAccept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').static Stringconfirm(com.codeborne.selenide.ModalOptions options) Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').static Stringcopy()Copy selected text or empty string if no text is selected to clipboard.static Stringdismiss()Dismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').static StringDismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').static Stringdismiss(com.codeborne.selenide.ModalOptions options) Dismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').static FileNB! URL must be properly encoded.static FileDownload file using a direct link.static Filestatic Filestatic com.codeborne.selenide.SelenideElementLocates the first element matching given CSS selectorstatic com.codeborne.selenide.SelenideElementLocates the Nth element matching given criteriastatic com.codeborne.selenide.SelenideElementelement(org.openqa.selenium.By seleniumSelector) Locates the first element matching given CSS selectorstatic com.codeborne.selenide.SelenideElementelement(org.openqa.selenium.By seleniumSelector, int index) Locates the Nth element matching given criteriastatic com.codeborne.selenide.SelenideElementelement(org.openqa.selenium.WebElement webElement) Wrap standard Selenium WebElement into SelenideElement to use additional methods likeSelenideElement.shouldHave(WebElementCondition...),SelenideElement.selectOption(String, String...)etc.static com.codeborne.selenide.ElementsCollectionLocates all elements matching given CSS selector.static com.codeborne.selenide.ElementsCollectionelements(Collection<? extends org.openqa.selenium.WebElement> elements) Wrap standard Selenium WebElement collection into SelenideElement collection to use additional methods likeSelenideElement.shouldHave(WebElementCondition...)etc.static com.codeborne.selenide.ElementsCollectionelements(org.openqa.selenium.By seleniumSelector) Locates all elements matching given CSS selector.static <T> @Nullable TexecuteAsyncJavaScript(String jsCode, Object... arguments) static <T> @Nullable TexecuteJavaScript(String jsCode, Object... arguments) static voidforward()Navigate browser forward to next pagestatic com.codeborne.selenide.SelenideElementstatic @Nullable com.codeborne.selenide.SelenideElementgetSelectedRadio(org.openqa.selenium.By radioField) Returns selected element in radio groupstatic StringReturns selected text or empty string if no text is selected.static StringGet current user agent from browser sessiongetWebDriverLogs(String logType) Same asgetWebDriverLogs(String, Level)getWebDriverLogs(String logType, Level logLevel) Getting and filtering of the WebDriver logs for specified LogType by specified logging level
For example to get WebDriver Browser's console output (including JS info, warnings, errors, etc.static voidinNewBrowser(com.codeborne.selenide.Config config, Runnable lambda) Open a new browser (with given settings), and run given code block in this browser.static voidinNewBrowser(Runnable lambda) Open a new browser (with the same settings as the default browser), and run given code block in this browser.static com.codeborne.selenide.LocalStorageAccess browser's local storage.static voidopen()Open an empty browser (without opening any pages).static voidopen(com.codeborne.selenide.Config config) Open an empty browser with given config.static voidThe main starting point in your tests.static voidopen(String relativeOrAbsoluteUrl, com.codeborne.selenide.AuthenticationType authenticationType, com.codeborne.selenide.Credentials credentials) The main starting point in your tests.static voidOpens browser with given config.static <PageObjectClass>
PageObjectClassOpen a web page and create PageObject for it.static voidThe main starting point in your tests.static <PageObjectClass>
PageObjectClassopen(String relativeOrAbsoluteUrl, String domain, String login, String password, Class<PageObjectClass> pageObjectClassClass) Open a web page using Basic Auth credentials and create PageObject for it.static voidstatic <PageObjectClass>
PageObjectClassOpen a web page and create PageObject for it.static voidstatic <PageObjectClass>
PageObjectClassopen(URL absoluteUrl, String domain, String login, String password, Class<PageObjectClass> pageObjectClassClass) Open a web page using Basic Auth credentials and create PageObject for it.static <PageObjectClass>
PageObjectClassCreate a Page Object instancestatic <PageObjectClass>
PageObjectClasspage(PageObjectClass... reified) Create a Page Object instancestatic <PageObjectClass,T extends PageObjectClass>
PageObjectClasspage(T pageObject) Initialize a given Page Object instancestatic Stringprompt()Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').static StringAccept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').static StringAccept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').static StringAccept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').static voidrefresh()Reload current pagestatic @Nullable Stringscreenshot(String fileName) Take the screenshot of current page and save to file "fileName.png" (and optionally, "fileName.html") File "fileName.png" is created always, even ifConfiguration.screenshots == falseFile "fileName.html" is created only ifConfiguration.savePageSource == truestatic <T> @Nullable Tscreenshot(org.openqa.selenium.OutputType<T> outputType) Take the screenshot of current page and return it.static org.openqa.selenium.remote.SessionIdGet current browser session idstatic com.codeborne.selenide.SessionStorageAccess browser's session storage.static voidsleep(long milliseconds) Not recommended.static com.codeborne.selenide.SelenideTargetLocatorswitchTo()Switch to window/tab/frame/parentFrame/innerFrame/alert.static @Nullable Stringtitle()static voidupdateHash(String hash) Update the hash of the window location.static voidusing(org.openqa.selenium.WebDriver webDriver, com.codeborne.selenide.proxy.SelenideProxyServer proxy, Runnable lambda) static voidstatic com.codeborne.selenide.SelenideWaitWait()Create an instance ofFluentWaitwith Selenide timeout/polling.static com.codeborne.selenide.Conditional<org.openqa.selenium.WebDriver>static voidzoom(double factor) Zoom current page (in or out).
-
Constructor Details
-
Selenide
public Selenide()
-
-
Method Details
-
open
The main starting point in your tests. Open a browser window with given URL.If browser window was already opened before, it will be reused.
Don't bother about closing the browser - it will be closed automatically when all your tests are done.
- Parameters:
relativeOrAbsoluteUrl- If not starting with "http://" or "https://" or "file://", it's considered to be relative URL. In this case, it's prepended by baseUrl
-
open
Opens browser with given config. If there was already an opened browser with different config, it will be closed. -
open
- See Also:
-
open
The main starting point in your tests.Open a browser window with given URL and credentials for basic authentication
If browser window was already opened before, it will be reused.
Don't bother about closing the browser - it will be closed automatically when all your tests are done.
If not starting with "http://" or "https://" or "file://", it's considered to be relative URL.
In this case, it's prepended by baseUrl
- Parameters:
domain- Name of domain to apply Basic Auth. 1. If empty, Basic Auth will be applied to all domains. 2. If non-empty, Basic Auth will be applied only to URLs containing this domain. 2.1. May contain multiple domain names (delimited by "," or "|").
-
open
public static void open(String relativeOrAbsoluteUrl, com.codeborne.selenide.AuthenticationType authenticationType, com.codeborne.selenide.Credentials credentials) The main starting point in your tests.Open browser and pass authentication using build-in proxy.
A common authenticationType is "Basic". See Web HTTP reference for other types.
This method can only work if -
Configuration.proxyEnabled == true- See Also:
-
open
- See Also:
-
open
public static void open()Open an empty browser (without opening any pages). E.g. useful for starting mobile applications in Appium. -
open
public static void open(com.codeborne.selenide.Config config) Open an empty browser with given config. If there was already an opened browser with different config, it will be closed. -
webdriver
public static com.codeborne.selenide.Conditional<org.openqa.selenium.WebDriver> webdriver() -
using
-
using
public static void using(org.openqa.selenium.WebDriver webDriver, com.codeborne.selenide.proxy.SelenideProxyServer proxy, Runnable lambda) -
inNewBrowser
Open a new browser (with the same settings as the default browser), and run given code block in this browser.In the end, the browser will be closed.
-
inNewBrowser
Open a new browser (with given settings), and run given code block in this browser.In the end, the browser will be closed.
- Since:
- 7.6.0
-
updateHash
Update the hash of the window location. Useful to navigate in ajax apps without reloading the page, since open(url) makes a full page reload.- Parameters:
hash- value for window.location.hash - Accept either "#hash" or "hash".
-
open
public static <PageObjectClass> PageObjectClass open(String relativeOrAbsoluteUrl, Class<PageObjectClass> pageObjectClassClass) Open a web page and create PageObject for it.- Returns:
- PageObject of given class
-
open
public static <PageObjectClass> PageObjectClass open(URL absoluteUrl, Class<PageObjectClass> pageObjectClassClass) Open a web page and create PageObject for it.- Returns:
- PageObject of given class
-
open
public static <PageObjectClass> PageObjectClass open(String relativeOrAbsoluteUrl, String domain, String login, String password, Class<PageObjectClass> pageObjectClassClass) Open a web page using Basic Auth credentials and create PageObject for it.- Returns:
- PageObject of given class
-
open
public static <PageObjectClass> PageObjectClass open(URL absoluteUrl, String domain, String login, String password, Class<PageObjectClass> pageObjectClassClass) Open a web page using Basic Auth credentials and create PageObject for it.- Returns:
- PageObject of given class
-
closeWindow
public static void closeWindow()Close the current window, quitting the browser if it's the last window currently open.- See Also:
-
WebDriver.close()
-
closeWebDriver
public static void closeWebDriver()Close the browser if it's open.
NB! Method quits this driver, closing every associated window.
- See Also:
-
WebDriver.quit()
-
refresh
public static void refresh()Reload current page -
back
public static void back()Navigate browser back to previous page -
forward
public static void forward()Navigate browser forward to next page -
title
- Returns:
- title of the page
-
sleep
public static void sleep(long milliseconds) Not recommended. Test should not sleep, but should wait for some condition instead.
Implementation detail: method
Thread.sleep(long)is not guaranteed to sleep exactly given number of milliseconds, it can awake earlier. That's why we need to use a loop to guarantee the sleep duration.- Parameters:
milliseconds- Time to sleep in milliseconds
-
screenshot
Take the screenshot of current page and save to file "fileName.png" (and optionally, "fileName.html")- File "fileName.png" is created always, even if
Configuration.screenshots == false - File "fileName.html" is created only if
Configuration.savePageSource == true
- Parameters:
fileName- Name of file (without extension) to save PNG (and HTML) to- Returns:
- URL of screenshot file
- File "fileName.png" is created always, even if
-
screenshot
@CanIgnoreReturnValue public static <T> @Nullable T screenshot(org.openqa.selenium.OutputType<T> outputType) Take the screenshot of current page and return it.- Parameters:
outputType- type of the returned screenshot- Returns:
- The screenshot (as bytes, base64 or temporary file) or null if webdriver does not support taking screenshots.
-
$
public static com.codeborne.selenide.SelenideElement $(org.openqa.selenium.WebElement webElement) Wrap standard Selenium WebElement into SelenideElement to use additional methods likeSelenideElement.should(WebElementCondition...),SelenideElement.selectOption(String, String...)etc.- Parameters:
webElement- standard Selenium WebElement- Returns:
- given WebElement wrapped into SelenideElement
-
$
Locates the first element matching given CSS selector (lazy evaluation)- Parameters:
cssSelector- any CSS selector like "input[name='first_name']" or "#messages .new_message"- Returns:
- SelenideElement
- See Also:
-
$x
Locates the first element matching given XPATH expression (lazy evaluation)- Parameters:
xpathExpression- any XPATH expression //*[@id='value'] //E[contains(@A, 'value')]- Returns:
- SelenideElement which locates elements via XPath
- See Also:
-
$
public static com.codeborne.selenide.SelenideElement $(org.openqa.selenium.By seleniumSelector) Locates the first element matching given CSS selector (lazy evaluation)- Parameters:
seleniumSelector- any Selenium selector like By.id(), By.name() etc.- Returns:
- SelenideElement
- See Also:
-
$
public static com.codeborne.selenide.SelenideElement $(org.openqa.selenium.By seleniumSelector, int index) - See Also:
-
$
Locates the Nth element matching given criteria (lazy evaluation)- Parameters:
cssSelector- any CSS selector like "input[name='first_name']" or "#messages .new_message"index- 0..N- Returns:
- SelenideElement
- See Also:
-
$$
public static com.codeborne.selenide.ElementsCollection $$(Collection<? extends org.openqa.selenium.WebElement> elements) Initialize collection with Elements -
$$
Locates all elements matching given CSS selector (lazy evaluation).Methods returns an ElementsCollection which is a list of WebElement objects that can be iterated, and at the same time is implementation of WebElement interface, meaning that you can call methods .sendKeys(), click() etc. on it.
- Parameters:
cssSelector- any CSS selector like "input[name='first_name']" or "#messages .new_message"- Returns:
- empty list if element was no found
- See Also:
-
$$x
Locates all elements matching given XPATH expression (lazy evaluation)Methods returns an ElementsCollection which is a list of WebElement objects that can be iterated, and at the same time is implementation of WebElement interface, meaning that you can call methods .sendKeys(), click() etc. on it.
- Parameters:
xpathExpression- any XPATH expression //*[@id='value'] //E[contains(@A, 'value')]- Returns:
- ElementsCollection which locates elements via XPath
- See Also:
-
$$
public static com.codeborne.selenide.ElementsCollection $$(org.openqa.selenium.By seleniumSelector) Locates all elements matching given CSS selector.Method returns an ElementsCollection which is a list of WebElement objects that can be iterated, and at the same time is implementation of WebElement interface, meaning that you can call methods .sendKeys(), click() etc. on it.
- Parameters:
seleniumSelector- any Selenium selector like By.id(), By.name() etc.- Returns:
- empty list if element was no found
- See Also:
-
element
public static com.codeborne.selenide.SelenideElement element(org.openqa.selenium.WebElement webElement) Wrap standard Selenium WebElement into SelenideElement to use additional methods likeSelenideElement.shouldHave(WebElementCondition...),SelenideElement.selectOption(String, String...)etc.- Parameters:
webElement- standard Selenium WebElement- Returns:
- given WebElement wrapped into SelenideElement
-
element
Locates the first element matching given CSS selector- Parameters:
cssSelector- any CSS selector like "input[name='first_name']" or "#messages .new_message"- Returns:
- SelenideElement
- See Also:
-
element
public static com.codeborne.selenide.SelenideElement element(org.openqa.selenium.By seleniumSelector) Locates the first element matching given CSS selector- Parameters:
seleniumSelector- any Selenium selector likeBy.id(String),By.name(String)etc.- Returns:
- SelenideElement
- See Also:
-
element
public static com.codeborne.selenide.SelenideElement element(org.openqa.selenium.By seleniumSelector, int index) Locates the Nth element matching given criteria- Parameters:
seleniumSelector- any Selenium selector likeBy.id(String),By.name(String)etc.index- 0..N- Returns:
- SelenideElement
- See Also:
-
element
Locates the Nth element matching given criteria- Parameters:
cssSelector- any CSS selector like"input[name='first_name']"or"#messages .new_message"index- 0..N- Returns:
- SelenideElement
- See Also:
-
elements
public static com.codeborne.selenide.ElementsCollection elements(Collection<? extends org.openqa.selenium.WebElement> elements) Wrap standard Selenium WebElement collection into SelenideElement collection to use additional methods likeSelenideElement.shouldHave(WebElementCondition...)etc.- Parameters:
elements- standard Selenium WebElement collection- Returns:
- given WebElement collection wrapped into SelenideElement collection
-
elements
Locates all elements matching given CSS selector.Method returns an ElementsCollection which is a list of WebElement objects that can be iterated, and at the same time is implementation of WebElement interface, meaning that you can call methods
WebElement.sendKeys(CharSequence...),WebElement.click()etc. on it.- Parameters:
cssSelector- any CSS selector like "input[name='first_name']" or "#messages .new_message"- Returns:
- empty list if element was no found
- See Also:
-
elements
public static com.codeborne.selenide.ElementsCollection elements(org.openqa.selenium.By seleniumSelector) Locates all elements matching given CSS selector.Method returns an ElementsCollection which is a list of WebElement objects that can be iterated, and at the same time is implementation of WebElement interface, meaning that you can call methods
WebElement.sendKeys(CharSequence...),WebElement.click()etc. on it.- Parameters:
seleniumSelector- any Selenium selector like By.id(), By.name() etc.- Returns:
- empty list if element was no found
- See Also:
-
executeJavaScript
@CanIgnoreReturnValue public static <T> @Nullable T executeJavaScript(String jsCode, Object... arguments) - See Also:
-
JavascriptExecutor.executeScript(String, java.lang.Object...)
-
executeAsyncJavaScript
@CanIgnoreReturnValue public static <T> @Nullable T executeAsyncJavaScript(String jsCode, Object... arguments) - See Also:
-
JavascriptExecutor.executeAsyncScript(String, java.lang.Object...)
-
getSelectedRadio
public static @Nullable com.codeborne.selenide.SelenideElement getSelectedRadio(org.openqa.selenium.By radioField) Returns selected element in radio group- Returns:
- null if nothing selected
-
confirm
Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').- Returns:
- actual dialog text
-
confirm
Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').- Parameters:
expectedDialogText- if not null, check that confirmation dialog displays this message (case-sensitive)- Returns:
- actual dialog text
- Throws:
com.codeborne.selenide.ex.DialogTextMismatch- if confirmation message differs from expected message
-
confirm
Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').- Parameters:
options- parameters: timeout, expected texts etc.- Returns:
- actual dialog text
- Throws:
com.codeborne.selenide.ex.DialogTextMismatch- if confirmation message differs from expected message
-
prompt
Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').- Returns:
- actual dialog text
-
prompt
Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').- Parameters:
inputText- if not null, sets value in prompt dialog input- Returns:
- actual dialog text
-
prompt
@CanIgnoreReturnValue public static String prompt(@Nullable String expectedDialogText, @Nullable String inputText) Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').- Parameters:
expectedDialogText- if not null, check that confirmation dialog displays this message (case-sensitive)inputText- if not null, sets value in prompt dialog input- Returns:
- actual dialog text
- Throws:
com.codeborne.selenide.ex.DialogTextMismatch- if confirmation message differs from expected message
-
prompt
@CanIgnoreReturnValue public static String prompt(com.codeborne.selenide.ModalOptions options, @Nullable String inputText) Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'prompt').- Parameters:
options- parameters: timeout, expected texts etc.inputText- if not null, sets value in prompt dialog input- Returns:
- actual dialog text
- Throws:
com.codeborne.selenide.ex.DialogTextMismatch- if confirmation message differs from expected message
-
dismiss
Dismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').- Returns:
- actual dialog text
-
dismiss
Dismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').- Parameters:
expectedDialogText- if not null, check that confirmation dialog displays this message (case-sensitive)- Returns:
- actual dialog text
- Throws:
com.codeborne.selenide.ex.DialogTextMismatch- if confirmation message differs from expected message
-
dismiss
Dismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').- Parameters:
options- if not null, check that confirmation dialog displays this message (case-sensitive)- Returns:
- actual dialog text
- Throws:
com.codeborne.selenide.ex.DialogTextMismatch- if confirmation message differs from expected message
-
switchTo
public static com.codeborne.selenide.SelenideTargetLocator switchTo()Switch to window/tab/frame/parentFrame/innerFrame/alert. Allows switching to window by title, index, name etc.Similar to
WebDriver.switchTo(), but all methods wait until frame/window/alert appears if it's not visible yet (like other Selenide methods).- Returns:
- SelenideTargetLocator
-
getFocusedElement
public static com.codeborne.selenide.SelenideElement getFocusedElement()- Returns:
- the element that currently is focused, or null if none of elements if focused
-
getSelectedText
Returns selected text or empty string if no text is selected.- Returns:
- selected text
-
copy
Copy selected text or empty string if no text is selected to clipboard.- Returns:
- the copied text
- See Also:
-
clipboard()Clipboard
-
page
Create a Page Object instance -
page
Create a Page Object instance- Parameters:
reified- Don't pass any values here. It's Java Magic :)
-
page
public static <PageObjectClass,T extends PageObjectClass> PageObjectClass page(T pageObject) Initialize a given Page Object instance -
Wait
public static com.codeborne.selenide.SelenideWait Wait()Create an instance ofFluentWaitwith Selenide timeout/polling.Sample usage:
Wait().until(invisibilityOfElementLocated(By.id("magic-id")));- Returns:
- instance of org.openqa.selenium.support.ui.FluentWait
-
actions
public static org.openqa.selenium.interactions.Actions actions()With this method you can use Selenium Actions like described in the AdvancedUserInteractions page.actions() .sendKeys($(By.name("rememberMe")), "John") .click($(#rememberMe")) .click($(byText("Login"))) .build() .perform(); -
zoom
public static void zoom(double factor) Zoom current page (in or out).- Parameters:
factor- e.g. 1.1 or 2.0 or 0.5
-
getWebDriverLogs
Same asgetWebDriverLogs(String, Level) -
getWebDriverLogs
Getting and filtering of the WebDriver logs for specified LogType by specified logging level
For example to get WebDriver Browser's console output (including JS info, warnings, errors, etc. messages) you can use:
for(String logEntry : getWebDriverLogs(LogType.BROWSER, Level.ALL)) { Reporter.log(logEntry + "<br>"); }
Be aware that currently "manage().logs()" is in the Beta stage, but it is beta-then-nothing :)- Parameters:
logType- WebDriver supported log typeslogLevel- logging level that will be used to control logging output- Returns:
- list of log entries
- See Also:
-
LogTypeLevel
-
clearBrowserCookies
public static void clearBrowserCookies()Clear browser cookies.It can be useful e.g. if you are trying to avoid restarting browser between tests
-
clearBrowserLocalStorage
public static void clearBrowserLocalStorage()Clear browser local storage.In case if you need to be sure that browser's localStorage is empty
-
getUserAgent
Get current user agent from browser session- Returns:
- browser user agent
-
atBottom
public static boolean atBottom()Return true if bottom of the page is reachedUseful if you need to scroll down by x pixels unknown number of times.
-
download
NB! URL must be properly encoded. E.g. instead of "/files/ж.txt", it should be "/files/%D0%B6.txt" -
download
- See Also:
-
download
- See Also:
-
download
Download file using a direct link. This method download file like it would be done in currently opened browser: it adds all cookies and "User-Agent" header to the downloading request.Download fails if specified timeout is exceeded
- Parameters:
url- either relative or absolute url NB! URL must be properly encoded. E.g. instead of "/files/ж.txt", it should be "/files/%D0%B6.txt"timeoutMs- specific timeout in ms- Returns:
- downloaded File in folder `Configuration.reportsFolder`
- Throws:
com.codeborne.selenide.ex.FileNotDownloadedError- if failed to download fileURISyntaxException- if given url has invalid syntax
-
localStorage
public static com.codeborne.selenide.LocalStorage localStorage()Access browser's local storage. Allows setting, getting, removing items as well as getting the size and clear the storage.- Returns:
- LocalStorage
-
sessionStorage
public static com.codeborne.selenide.SessionStorage sessionStorage()Access browser's session storage. Allows setting, getting, removing items as well as getting the size, check for contains item and clear the storage.- Returns:
- sessionStorage
-
clipboard
public static com.codeborne.selenide.Clipboard clipboard()Provide access to system clipboard, allows get and set String content. Default implementation acts viaToolkitand supports only local runs.Remote runs support can be implemented via plugins. Plugin for Selenoid supports clipboard since v1.1.0.
- Returns:
- Clipboard
- See Also:
-
- selenide-selenoid
Pay attention that Clipboard is shared resource for instance where tests runs and keep in mind while developing test suite with multiple tests for clipboard.
- selenide-selenoid
-
sessionId
public static org.openqa.selenium.remote.SessionId sessionId()Get current browser session id- Returns:
- SessionId
-