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.shouldHave(Condition...),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 Stringconfirm(com.codeborne.selenide.ModalOptions options) 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 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(com.codeborne.selenide.ModalOptions options) 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 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(Condition...),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(Condition...)etc.static com.codeborne.selenide.ElementsCollectionelements(org.openqa.selenium.By seleniumSelector) Locates all elements matching given CSS selector.static <T> TexecuteAsyncJavaScript(String jsCode, Object... arguments) static <T> TexecuteJavaScript(String jsCode, Object... arguments) static voidforward()Navigate browser forward to next pagestatic org.openqa.selenium.WebElementstatic 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 com.codeborne.selenide.LocalStorageAccess browser's local storage.static voidopen()Open an empty browser (without opening any pages).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 voidopen(String relativeOrAbsoluteUrl, com.codeborne.selenide.AuthenticationType authenticationType, String login, String password) Deprecated.AFAIK "login+password" combination is only used in BASIC authentication.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 Stringscreenshot(String fileName) Take the screenshot of current page and save to file fileName.html and fileName.pngstatic <T> 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 Stringtitle()static voidupdateHash(String hash) Update the hash of the window location.static voidstatic com.codeborne.selenide.SelenideWaitWait()Create a org.openqa.selenium.support.ui.FluentWait instance with 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
- 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
-
open
@Deprecated public static void open(String relativeOrAbsoluteUrl, com.codeborne.selenide.AuthenticationType authenticationType, String login, String password) Deprecated.AFAIK "login+password" combination is only used in BASIC authentication. If you need basic auth, useopen(String, AuthenticationType, Credentials)withBasicAuthCredentialsparameter.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:
-
- Web HTTP reference
AuthenticationType
-
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:
-
- Web HTTP reference
AuthenticationTypeCredentials
-
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. -
webdriver
@CheckReturnValue @Nonnull public static com.codeborne.selenide.Conditional<org.openqa.selenium.WebDriver> webdriver()- Since:
- 5.23.0
-
using
-
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
@CheckReturnValue @Nonnull 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
@CheckReturnValue @Nonnull 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
@CheckReturnValue @Nonnull 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
@CheckReturnValue @Nonnull 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.html and fileName.png- Parameters:
fileName- Name of file (without extension) to save HTML and PNG to- Returns:
- The name of resulting file
-
screenshot
@CheckReturnValue @Nullable public static <T> 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.
-
$
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement $(org.openqa.selenium.WebElement webElement) Wrap standard Selenium WebElement into SelenideElement to use additional methods likeSelenideElement.shouldHave(Condition...),SelenideElement.selectOption(String, String...)etc.- Parameters:
webElement- standard Selenium WebElement- Returns:
- given WebElement wrapped into SelenideElement
-
$
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement $(String cssSelector) 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
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement $x(String xpathExpression) 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:
-
$
@CheckReturnValue @Nonnull 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:
-
$
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement $(org.openqa.selenium.By seleniumSelector, int index) - See Also:
-
$
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement $(String cssSelector, int index) 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:
-
$$
@CheckReturnValue @Nonnull public static com.codeborne.selenide.ElementsCollection $$(Collection<? extends org.openqa.selenium.WebElement> elements) Initialize collection with Elements -
$$
@CheckReturnValue @Nonnull public static com.codeborne.selenide.ElementsCollection $$(String cssSelector) 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
@CheckReturnValue @Nonnull public static com.codeborne.selenide.ElementsCollection $$x(String xpathExpression) 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:
-
$$
@CheckReturnValue @Nonnull 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
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement element(org.openqa.selenium.WebElement webElement) Wrap standard Selenium WebElement into SelenideElement to use additional methods likeSelenideElement.shouldHave(Condition...),SelenideElement.selectOption(String, String...)etc.- Parameters:
webElement- standard Selenium WebElement- Returns:
- given WebElement wrapped into SelenideElement
-
element
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement element(String cssSelector) 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
@CheckReturnValue @Nonnull 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
@CheckReturnValue @Nonnull 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
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideElement element(String cssSelector, int index) 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
@CheckReturnValue @Nonnull 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(Condition...)etc.- Parameters:
elements- standard Selenium WebElement collection- Returns:
- given WebElement collection wrapped into SelenideElement collection
-
elements
@CheckReturnValue @Nonnull public static com.codeborne.selenide.ElementsCollection elements(String cssSelector) 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
@CheckReturnValue @Nonnull 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
- See Also:
-
JavascriptExecutor.executeScript(String, java.lang.Object...)
-
executeAsyncJavaScript
- See Also:
-
JavascriptExecutor.executeAsyncScript(String, java.lang.Object...)
-
getSelectedRadio
@CheckReturnValue @Nullable public static 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- Since:
- 6.6.0
-
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
@Nullable 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
@Nullable 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- Since:
- 6.6.0
-
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- Since:
- 6.6.0
-
switchTo
@Nonnull @CheckReturnValue 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
@CheckReturnValue @Nullable public static org.openqa.selenium.WebElement getFocusedElement()- Returns:
- WebElement, not SelenideElement! which has focus on it
-
getSelectedText
Returns selected text or empty string if no text is selected.- Returns:
- selected text
- Since:
- 6.11.0
-
copy
Copy selected text or empty string if no text is selected to clipboard.- Returns:
- the copied text
- Since:
- 6.11.0
- See Also:
-
clipboard()Clipboard
-
page
@CheckReturnValue @Nonnull public static <PageObjectClass> PageObjectClass page(Class<PageObjectClass> pageObjectClass) Create a Page Object instance -
page
@CheckReturnValue @Nonnull public static <PageObjectClass> PageObjectClass page(PageObjectClass... reified) Create a Page Object instance- Parameters:
reified- Don't pass any values here. It's Java Magic :)- Since:
- 6.8.0
-
page
@CheckReturnValue @Nonnull public static <PageObjectClass,T extends PageObjectClass> PageObjectClass page(T pageObject) Initialize a given Page Object instance -
Wait
@CheckReturnValue @Nonnull public static com.codeborne.selenide.SelenideWait Wait()Create a org.openqa.selenium.support.ui.FluentWait instance with Selenide timeout/polling.Sample usage:
Wait().until(invisibilityOfElementLocated(By.id("magic-id")));- Returns:
- instance of org.openqa.selenium.support.ui.FluentWait
-
actions
@CheckReturnValue @Nonnull 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
@Nonnull @CheckReturnValue public static List<String> 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. 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 :)
List of the unsupported browsers and issues:
http://bit.ly/RZcmrM
http://bit.ly/1nZTaqu- 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
@CheckReturnValue 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
@Nonnull @CheckReturnValue public static File download(String url) throws IOException, URISyntaxException NB! URL must be properly encoded. E.g. instead of "/files/ж.txt", it should be "/files/%D0%B6.txt" -
download
- Throws:
IOException- See Also:
-
download
- Throws:
IOException- See Also:
-
download
@Nonnull @CheckReturnValue public static File download(String url, long timeoutMs) throws IOException, URISyntaxException 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:
IOException- if failed to download fileURISyntaxException- if given url has invalid syntax
-
localStorage
@Nonnull @CheckReturnValue 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
- Since:
- 5.15.0
-
sessionStorage
@Nonnull @CheckReturnValue 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
- Since:
- 5.18.1
-
clipboard
@Nonnull @CheckReturnValue 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
- Since:
- 5.20.0
- 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
@Nonnull @CheckReturnValue public static org.openqa.selenium.remote.SessionId sessionId()Get current browser session Id- Returns:
- SessionId
-