public class Selenide
extends java.lang.Object
open(String) for opening the tested application page and
$(String) for searching web elements.| Constructor and Description |
|---|
Selenide() |
| Modifier and Type | Method and Description |
|---|---|
static SelenideElement |
$(org.openqa.selenium.By seleniumSelector)
Find the first element matching given CSS selector
|
static SelenideElement |
$(org.openqa.selenium.By seleniumSelector,
int index) |
static SelenideElement |
$(java.lang.String cssSelector)
Find the first element matching given CSS selector
|
static SelenideElement |
$(java.lang.String cssSelector,
int index)
Find the Nth element matching given criteria
|
static SelenideElement |
$(org.openqa.selenium.WebElement webElement)
Wrap standard Selenium WebElement into SelenideElement
to use additional methods like shouldHave(), selectOption() etc.
|
static SelenideElement |
$(org.openqa.selenium.WebElement parent,
org.openqa.selenium.By seleniumSelector)
Deprecated.
please use $(parent).$(By) which is the same
(method will not be removed until 4.x or later)
|
static SelenideElement |
$(org.openqa.selenium.WebElement parent,
org.openqa.selenium.By seleniumSelector,
int index)
Deprecated.
please use $(parent).$(By, int) which is the same
(method will not be removed until 4.x or later)
|
static SelenideElement |
$(org.openqa.selenium.WebElement parent,
java.lang.String cssSelector)
Deprecated.
please use $(parent).$(String) which is the same
(method will not be removed until 4.x or later)
|
static SelenideElement |
$(org.openqa.selenium.WebElement parent,
java.lang.String cssSelector,
int index)
Deprecated.
please use $(parent).$(String, int) which is the same
(method will not be removed until 4.x or later)
|
static ElementsCollection |
$$(org.openqa.selenium.By seleniumSelector)
Find all elements matching given CSS selector.
|
static ElementsCollection |
$$(java.util.Collection<? extends org.openqa.selenium.WebElement> elements)
Initialize collection with Elements
|
static ElementsCollection |
$$(java.lang.String cssSelector)
Find all elements matching given CSS selector.
|
static ElementsCollection |
$$(org.openqa.selenium.WebElement parent,
org.openqa.selenium.By seleniumSelector)
Deprecated.
please use $(parent).$$(By) which is the same
(method will not be removed until 4.x or later)
|
static ElementsCollection |
$$(org.openqa.selenium.WebElement parent,
java.lang.String cssSelector)
Deprecated.
please use $(parent).$$(String) which is the same
(method will not be removed until 4.x or later)
|
static org.openqa.selenium.interactions.Actions |
actions()
With this method you can use Selenium Actions like described in the
AdvancedUserInteractions page.
|
static void |
assertNoJavascriptErrors()
Check if there is not JS errors on the page
|
static void |
back()
Navigate browser back to previous page
|
static void |
close()
Close the browser if it's open
|
static java.lang.String |
confirm()
Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').
|
static java.lang.String |
confirm(java.lang.String expectedDialogText)
Accept (Click "Yes" or "Ok") in the confirmation dialog (javascript 'alert' or 'confirm').
|
static java.lang.String |
dismiss()
Dismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').
|
static java.lang.String |
dismiss(java.lang.String expectedDialogText)
Dismiss (click "No" or "Cancel") in the confirmation dialog (javascript 'alert' or 'confirm').
|
static <T> T |
executeJavaScript(java.lang.String jsCode,
java.lang.Object... arguments)
Executes JavaScript
|
static void |
forward()
Navigate browser forward to next page
|
static SelenideElement |
getElement(org.openqa.selenium.By criteria)
Find the first element matching given criteria
|
static SelenideElement |
getElement(org.openqa.selenium.By criteria,
int index)
Find the Nth element matching given criteria
|
static ElementsCollection |
getElements(org.openqa.selenium.By criteria)
Find all elements matching given CSS selector
|
static org.openqa.selenium.WebElement |
getFocusedElement() |
static java.util.List<java.lang.String> |
getJavascriptErrors()
Get JavaScript errors that happened on this page.
|
static SelenideElement |
getSelectedRadio(org.openqa.selenium.By radioField)
Returns selected element in radio group
|
static java.util.List<java.lang.String> |
getWebDriverLogs(java.lang.String logType)
Same as com.codeborne.selenide.Selenide#getWebDriverLogs(java.lang.String, java.util.logging.Level)
|
static java.util.List<java.lang.String> |
getWebDriverLogs(java.lang.String logType,
java.util.logging.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 void |
onConfirmReturn(boolean confirmReturnValue)
Mock confirm dialog that return given value
|
static void |
open(java.lang.String relativeOrAbsoluteUrl)
The main starting point in your tests.
|
static <PageObjectClass> |
open(java.lang.String relativeOrAbsoluteUrl,
java.lang.Class<PageObjectClass> pageObjectClassClass)
Open a web page and create PageObject for it.
|
static void |
open(java.net.URL absoluteUrl) |
static <PageObjectClass> |
open(java.net.URL absoluteUrl,
java.lang.Class<PageObjectClass> pageObjectClassClass)
Open a web page and create PageObject for it.
|
static <PageObjectClass> |
page(java.lang.Class<PageObjectClass> pageObjectClass)
Create a Page Object instance.
|
static <PageObjectClass,T extends PageObjectClass> |
page(T pageObject)
Create a Page Object instance.
|
static void |
refresh()
Reload current page
|
static java.lang.String |
screenshot(java.lang.String fileName)
Take the screenshot of current page and save to file fileName.html and fileName.png
|
static SelenideElement |
selectRadio(org.openqa.selenium.By radioField,
java.lang.String value)
Not recommended.
|
static void |
sleep(long milliseconds)
Not recommended.
|
static SelenideTargetLocator |
switchTo()
Switch to window/tab/frame/parentFrame/innerFrame/alert.
|
static java.lang.String |
title() |
static void |
updateHash(java.lang.String hash)
Update the hash of the window location.
|
static org.openqa.selenium.support.ui.FluentWait<org.openqa.selenium.WebDriver> |
Wait()
Create a org.openqa.selenium.support.ui.FluentWait instance with Selenide timeout/polling.
|
static void |
zoom(double factor)
Zoom current page (in or out).
|
public static Navigator navigator
public static void open(java.lang.String relativeOrAbsoluteUrl)
relativeOrAbsoluteUrl - If not starting with "http://" or "https://" or "file://", it's considered to be relative URL.
In this case, it's prepended by baseUrlpublic static void open(java.net.URL absoluteUrl)
open(String)public static void updateHash(java.lang.String hash)
hash - value for window.location.hash - Accept either "#hash" or "hash".public static <PageObjectClass> PageObjectClass open(java.lang.String relativeOrAbsoluteUrl,
java.lang.Class<PageObjectClass> pageObjectClassClass)
public static <PageObjectClass> PageObjectClass open(java.net.URL absoluteUrl,
java.lang.Class<PageObjectClass> pageObjectClassClass)
public static void close()
public static void refresh()
public static void back()
public static void forward()
public static java.lang.String title()
public static void sleep(long milliseconds)
milliseconds - Time to sleep in millisecondspublic static java.lang.String screenshot(java.lang.String fileName)
fileName - Name of file (without extension) to save HTML and PNG topublic static SelenideElement $(org.openqa.selenium.WebElement webElement)
webElement - standard Selenium WebElementpublic static SelenideElement $(java.lang.String cssSelector)
cssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"public static SelenideElement $(org.openqa.selenium.By seleniumSelector)
seleniumSelector - any Selenium selector like By.id(), By.name() etc.public static SelenideElement $(org.openqa.selenium.By seleniumSelector, int index)
getElement(By, int)@Deprecated public static SelenideElement $(org.openqa.selenium.WebElement parent, java.lang.String cssSelector)
parent - the WebElement to search elements incssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"Find the first element matching given CSS selectorpublic static SelenideElement $(java.lang.String cssSelector, int index)
cssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"index - 0..N@Deprecated public static SelenideElement $(org.openqa.selenium.WebElement parent, java.lang.String cssSelector, int index)
parent - the WebElement to search elements incssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"index - 0..NFind the Nth element matching given criteria@Deprecated public static SelenideElement $(org.openqa.selenium.WebElement parent, org.openqa.selenium.By seleniumSelector)
parent - the WebElement to search elements inseleniumSelector - any Selenium selector like By.id(), By.name() etc.Find the first element matching given criteria@Deprecated public static SelenideElement $(org.openqa.selenium.WebElement parent, org.openqa.selenium.By seleniumSelector, int index)
parent - the WebElement to search elements inseleniumSelector - any Selenium selector like By.id(), By.name() etc.index - 0..NFind the Nth element matching given criteriapublic static ElementsCollection $$(java.util.Collection<? extends org.openqa.selenium.WebElement> elements)
elements - public static ElementsCollection $$(java.lang.String cssSelector)
cssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"public static ElementsCollection $$(org.openqa.selenium.By seleniumSelector)
seleniumSelector - any Selenium selector like By.id(), By.name() etc.@Deprecated public static ElementsCollection $$(org.openqa.selenium.WebElement parent, java.lang.String cssSelector)
parent - the WebElement to search elements incssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"Find all elements matching given CSS selector inside given parent element
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.@Deprecated public static ElementsCollection $$(org.openqa.selenium.WebElement parent, org.openqa.selenium.By seleniumSelector)
public static SelenideElement getElement(org.openqa.selenium.By criteria)
criteria - instance of By: By.id(), By.className() etc.public static SelenideElement getElement(org.openqa.selenium.By criteria, int index)
criteria - instance of By: By.id(), By.className() etc.index - 0..Npublic static ElementsCollection getElements(org.openqa.selenium.By criteria)
criteria - instance of By: By.id(), By.className() etc.public static <T> T executeJavaScript(java.lang.String jsCode,
java.lang.Object... arguments)
public static SelenideElement selectRadio(org.openqa.selenium.By radioField, java.lang.String value)
$(radioField).selectRadio(value);
Select radio field by valueradioField - any By selector for finding radio fieldvalue - value to select (should match an attribute "value")public static SelenideElement getSelectedRadio(org.openqa.selenium.By radioField)
radioField - public static void onConfirmReturn(boolean confirmReturnValue)
confirmReturnValue - true = OK, false = CANCELpublic static java.lang.String confirm()
public static java.lang.String confirm(java.lang.String expectedDialogText)
expectedDialogText - if not null, check that confirmation dialog displays this message (case-sensitive)DialogTextMismatch - if confirmation message differs from expected messagepublic static java.lang.String dismiss()
public static java.lang.String dismiss(java.lang.String expectedDialogText)
expectedDialogText - if not null, check that confirmation dialog displays this message (case-sensitive)DialogTextMismatch - if confirmation message differs from expected messagepublic static SelenideTargetLocator switchTo()
public static org.openqa.selenium.WebElement getFocusedElement()
public static <PageObjectClass> PageObjectClass page(java.lang.Class<PageObjectClass> pageObjectClass)
PageFactory.initElements(WebDriver, Class)public static <PageObjectClass,T extends PageObjectClass> PageObjectClass page(T pageObject)
PageFactory.initElements(WebDriver, Class)public static org.openqa.selenium.support.ui.FluentWait<org.openqa.selenium.WebDriver> Wait()
Wait().until(invisibilityOfElementLocated(By.id("magic-id")));
public static org.openqa.selenium.interactions.Actions actions()
actions()
.sendKeys($(By.name("rememberMe")), "John")
.click($(#rememberMe"))
.click($(byText("Login")))
.build()
.perform();
public static java.util.List<java.lang.String> getJavascriptErrors()
public static void assertNoJavascriptErrors()
throws JavaScriptErrorsFound
JavaScriptErrorsFoundpublic static void zoom(double factor)
factor - e.g. 1.1 or 2.0 or 0.5public static java.util.List<java.lang.String> getWebDriverLogs(java.lang.String logType)
public static java.util.List<java.lang.String> getWebDriverLogs(java.lang.String logType,
java.util.logging.Level logLevel)
for(String logEntry : getWebDriverLogs(LogType.BROWSER, Level.ALL)) {
Reporter.log(logEntry + "<br />");
}
logType - WebDriver supported log typeslogLevel - logging level that will be used to control logging outputorg.openqa.selenium.logging.LogType,,
Level