@ParametersAreNonnullByDefault
public interface SelenideElement
extends org.openqa.selenium.WebElement, org.openqa.selenium.WrapsDriver, org.openqa.selenium.internal.WrapsElement, org.openqa.selenium.interactions.Locatable, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.internal.HasIdentity
WebElement with additional methods like
shouldBe(Condition...) and shouldHave(Condition...)| Modifier and Type | Method and Description |
|---|---|
SelenideElement |
$(org.openqa.selenium.By selector)
Same as
find(String) |
SelenideElement |
$(org.openqa.selenium.By selector,
int index)
Same as
find(String, int) |
SelenideElement |
$(java.lang.String cssSelector)
Same as
find(String) |
SelenideElement |
$(java.lang.String cssSelector,
int index)
Same as
find(String, int) |
ElementsCollection |
$$(org.openqa.selenium.By selector)
Same as
findAll(By) |
ElementsCollection |
$$(java.lang.String cssSelector)
Same as
findAll(String) |
ElementsCollection |
$$x(java.lang.String xpath)
Short form of
webDriver.findElements(thisElement, By.xpath(xpath)) |
SelenideElement |
$x(java.lang.String xpath)
Locates the first matching element inside given element using xpath locator
|
SelenideElement |
$x(java.lang.String xpath,
int index)
Locates the Nth matching element inside given element using xpath locator
|
SelenideElement |
append(java.lang.String text)
Append given text to the text field and trigger "change" event.
|
SelenideElement |
as(java.lang.String alias)
Give this element a human-readable name
Caution: you probably don't need this method.
|
java.lang.String |
attr(java.lang.String attributeName)
Get the attribute of the element.
|
void |
click()
Click the element
|
void |
click(ClickOptions clickOption)
Click the element using
ClickOptions: $("#username").click(ClickOptions.usingJavaScript()) |
void |
click(int offsetX,
int offsetY)
Deprecated.
use
click(ClickOptions) with offsets |
SelenideElement |
closest(java.lang.String tagOrClass)
Locates closes ancestor element matching given criteria
For example, $("td").closest("table") could give some "table".
|
SelenideElement |
contextClick()
Click with right mouse button on this element
|
java.lang.String |
data(java.lang.String dataAttributeName)
Get value of attribute "data-dataAttributeName"
|
SelenideElement |
doubleClick()
Double click the element
|
java.io.File |
download()
Download file by clicking this element.
|
java.io.File |
download(DownloadOptions options) |
java.io.File |
download(FileFilter fileFilter)
Download file by clicking this element.
|
java.io.File |
download(long timeout)
Download file by clicking this element.
|
java.io.File |
download(long timeout,
FileFilter fileFilter)
Download file by clicking this element.
|
SelenideElement |
dragAndDropTo(java.lang.String targetCssSelector)
Drag and drop this element to the target
|
SelenideElement |
dragAndDropTo(java.lang.String targetCssSelector,
DragAndDropOptions options)
Drag and drop this element to the target via JS script
see resources/drag_and_drop_script
|
SelenideElement |
dragAndDropTo(org.openqa.selenium.WebElement target)
Drag and drop this element to the target
|
<ReturnType> |
execute(Command<ReturnType> command)
Execute custom implemented command (this command will not receive
any arguments through
Command.execute(SelenideElement, WebElementSource, Object[])
when executed). |
<ReturnType> |
execute(Command<ReturnType> command,
java.time.Duration timeout)
Execute custom implemented command with given timeout (this command will not receive
any arguments through
Command.execute(SelenideElement, WebElementSource, Object[])
when executed). |
boolean |
exists()
Checks if element exists true on the current page.
|
SelenideElement |
find(org.openqa.selenium.By selector)
Same as
find(String) |
SelenideElement |
find(org.openqa.selenium.By selector,
int index)
Same as
find(String, int) |
SelenideElement |
find(java.lang.String cssSelector)
Locates the first matching element inside given element
|
SelenideElement |
find(java.lang.String cssSelector,
int index)
Locates the Nth matching element inside given element
|
ElementsCollection |
findAll(org.openqa.selenium.By selector)
Short form of
webDriver.findElements(thisElement, selector) |
ElementsCollection |
findAll(java.lang.String cssSelector)
Short form of
webDriver.findElements(thisElement, By.cssSelector(cssSelector)) |
java.lang.String |
getAlias()
Element alias, which can be set with
as(String text) |
java.lang.String |
getAttribute(java.lang.String name) |
java.lang.String |
getCssValue(java.lang.String propertyName) |
java.lang.String |
getOwnText()
Get the text of the element WITHOUT children.
|
java.lang.String |
getSearchCriteria()
Return criteria by which this element is located
|
SelenideElement |
getSelectedOption()
Find (first) selected option from this select field
|
ElementsCollection |
getSelectedOptions()
Find all selected options from this select field
|
java.lang.String |
getSelectedText()
Get text of selected option in select field
|
java.lang.String |
getSelectedValue()
Get value of selected option in select field
|
java.lang.String |
getText()
Get the visible text of this element, including sub-elements without leading/trailing whitespace.
|
java.lang.String |
getValue()
Get the "value" attribute of the element
|
org.openqa.selenium.WebElement |
getWrappedElement() |
boolean |
has(Condition condition)
immediately returns true if element matches given condition
Method doesn't wait!
WARNING: This method can help implementing crooks, but it is not needed for typical ui tests.
|
SelenideElement |
hover()
Emulate "mouseOver" event.
|
SelenideElement |
hover(HoverOptions options)
Emulate "mouseOver" event.
|
java.lang.String |
innerHtml()
Get the HTML code of the element with children.
|
java.lang.String |
innerText()
Get the text code of the element with children.
|
boolean |
is(Condition condition)
immediately returns true if element matches given condition
Method doesn't wait!
WARNING: This method can help implementing crooks, but it is not needed for typical ui tests.
|
boolean |
isDisplayed()
Check if this element exists and visible.
|
boolean |
isImage()
Check if image is properly loaded.
|
SelenideElement |
lastChild()
Get last child element of this element
For example, $("tr").lastChild(); could give the last "td".
|
java.lang.String |
name()
Get the "name" attribute of the element
|
SelenideElement |
parent()
Get parent element of this element (lazy evaluation)
For example, $("td").parent() could give some "tr".
|
SelenideElement |
preceding(int index)
Get the preceding sibling element of this element
For example, $("td").preceding(0) will give the first preceding sibling element of "td"
|
SelenideElement |
pressEnter()
Press ENTER.
|
SelenideElement |
pressEscape()
Press ESCAPE.
|
SelenideElement |
pressTab()
Press TAB.
|
java.lang.String |
pseudo(java.lang.String pseudoElementName)
Get content of the pseudo-element
|
java.lang.String |
pseudo(java.lang.String pseudoElementName,
java.lang.String propertyName)
Get the property value of the pseudo-element
|
java.io.File |
screenshot()
Take screenshot of this element
|
java.awt.image.BufferedImage |
screenshotAsImage()
Take screenshot of this element
|
SelenideElement |
scrollIntoView(boolean alignToTop)
Ask browser to scrolls the element on which it's called into the visible area of the browser window.
|
SelenideElement |
scrollIntoView(java.lang.String scrollIntoViewOptions)
Ask browser to scrolls the element on which it's called into the visible area of the browser window.
|
SelenideElement |
scrollTo()
Ask browser to scroll to this element
|
void |
selectOption(int... index)
Select an option from dropdown list (by index)
|
void |
selectOption(java.lang.String... text)
Select an option from dropdown list (by text)
|
void |
selectOptionByValue(java.lang.String... value)
Select an option from dropdown list (by value)
|
void |
selectOptionContainingText(java.lang.String text)
Select an option from dropdown list that contains given text
|
SelenideElement |
selectRadio(java.lang.String value)
Select radio button
|
SelenideElement |
setSelected(boolean selected)
Set checkbox state to CHECKED or UNCHECKED.
|
SelenideElement |
setValue(java.lang.String text)
Implementation details:
|
SelenideElement |
should(Condition... condition)
Checks that given element meets all of given conditions.
|
SelenideElement |
should(Condition condition,
java.time.Duration timeout)
Wait until given element meets given condition (with given timeout)
|
SelenideElement |
shouldBe(Condition... condition)
Synonym for
should(com.codeborne.selenide.Condition...). |
SelenideElement |
shouldBe(Condition condition,
java.time.Duration timeout)
Wait until given element meets given condition (with given timeout)
|
SelenideElement |
shouldHave(Condition... condition)
Synonym for
should(com.codeborne.selenide.Condition...). |
SelenideElement |
shouldHave(Condition condition,
java.time.Duration timeout)
Wait until given element meets given condition (with given timeout)
|
SelenideElement |
shouldNot(Condition... condition)
Checks that given element does not meet given conditions.
|
SelenideElement |
shouldNot(Condition condition,
java.time.Duration timeout)
Wait until given element meets given condition (with given timeout)
|
SelenideElement |
shouldNotBe(Condition... condition)
Synonym for
shouldNot(com.codeborne.selenide.Condition...). |
SelenideElement |
shouldNotBe(Condition condition,
java.time.Duration timeout)
Wait until given element does NOT meet given condition (with given timeout)
|
SelenideElement |
shouldNotHave(Condition... condition)
Synonym for
shouldNot(com.codeborne.selenide.Condition...). |
SelenideElement |
shouldNotHave(Condition condition,
java.time.Duration timeout)
Wait until given element does NOT meet given condition (with given timeout)
|
SelenideElement |
sibling(int index)
Get the following sibling element of this element
For example, $("td").sibling(0) will give the first following sibling element of "td"
|
java.lang.String |
text()
Short form of
getText() |
java.lang.String |
toString()
Displays WebElement in human-readable format.
|
org.openqa.selenium.WebElement |
toWebElement() |
java.io.File |
uploadFile(java.io.File... file)
Upload file into file upload field.
|
java.io.File |
uploadFromClasspath(java.lang.String... fileName)
Upload file into file upload field.
|
java.lang.String |
val()
Get the "value" attribute of the element
Same as
getValue() |
SelenideElement |
val(java.lang.String text)
Same as
setValue(java.lang.String) |
SelenideElement |
waitUntil(Condition condition,
long timeoutMilliseconds)
Deprecated.
|
SelenideElement |
waitUntil(Condition condition,
long timeoutMilliseconds,
long pollingIntervalMilliseconds)
Deprecated.
|
SelenideElement |
waitWhile(Condition condition,
long timeoutMilliseconds)
Deprecated.
|
SelenideElement |
waitWhile(Condition condition,
long timeoutMilliseconds,
long pollingIntervalMilliseconds)
Deprecated.
|
@Nonnull @CanIgnoreReturnValue SelenideElement setValue(@Nullable java.lang.String text)
If Configuration.versatileSetValue is true, can work as 'selectOptionByValue', 'selectRadio'
If Configuration.fastSetValue is true, sets value by javascript instead of using Selenium built-in "sendKey" function and trigger "focus", "keydown", "keypress", "input", "keyup", "change" events.
In other case behavior will be:
1. WebElement.clear() 2. WebElement.sendKeys(text) 3. Trigger change event
text - Any text to enter into the text field or set by value for select/radio.SetValue@Nonnull @CanIgnoreReturnValue SelenideElement val(@Nullable java.lang.String text)
setValue(java.lang.String)Val@Nonnull @CanIgnoreReturnValue SelenideElement append(java.lang.String text)
Implementation details: This is the same as
1. WebElement.sendKeys(text) 2. Trigger change event
text - Any text to append into the text field.Append@Nonnull @CanIgnoreReturnValue SelenideElement pressEnter()
$("query").val("Aikido techniques").pressEnter();
Implementation details: Check that element is displayed and execute
WebElement.sendKeys(Keys.ENTER)
PressEnter@Nonnull @CanIgnoreReturnValue SelenideElement pressTab()
$("#to").val("stiven@seagal.com").pressTab();
Implementation details: Check that element is displayed and execute
WebElement.sendKeys(Keys.TAB)
PressTab@Nonnull @CanIgnoreReturnValue SelenideElement pressEscape()
$(".edit").click().pressEscape();
Implementation details: Check that element is displayed and execute
WebElement.sendKeys(Keys.ESCAPE)
PressEscape@CheckReturnValue @Nonnull java.lang.String getText()
getText in interface org.openqa.selenium.WebElementGetText,
NOT RECOMMENDED@CheckReturnValue @Nullable java.lang.String getAlias()
as(String text)GetAlias@CheckReturnValue @Nonnull java.lang.String text()
getText()WebElement.getText(),
GetText,
NOT RECOMMENDED@CheckReturnValue @Nonnull java.lang.String getOwnText()
GetOwnText,
NOT RECOMMENDED@CheckReturnValue @Nonnull java.lang.String innerText()
It can be used to get the text of a hidden element.
Short form of getAttribute("textContent") or getAttribute("innerText") depending on browser.
GetInnerText,
NOT RECOMMENDED@CheckReturnValue @Nonnull java.lang.String innerHtml()
It can be used to get the html of a hidden element.
Short form of getAttribute("innerHTML")
GetInnerHtml,
NOT RECOMMENDED@CheckReturnValue @Nullable java.lang.String attr(java.lang.String attributeName)
getAttribute(String)GetAttribute,
NOT RECOMMENDED@CheckReturnValue @Nullable java.lang.String name()
GetName,
NOT RECOMMENDED@CheckReturnValue @Nullable java.lang.String val()
getValue()Val,
NOT RECOMMENDED@CheckReturnValue @Nullable java.lang.String getValue()
GetValue,
NOT RECOMMENDED@CheckReturnValue
@Nonnull
java.lang.String pseudo(java.lang.String pseudoElementName,
java.lang.String propertyName)
pseudoElementName - pseudo-element name of the element,
":before", ":after", ":first-letter", ":first-line", ":selection"propertyName - property name of the pseudo-elementGetPseudoValue,
NOT RECOMMENDED@CheckReturnValue @Nonnull java.lang.String pseudo(java.lang.String pseudoElementName)
pseudoElementName - pseudo-element name of the element, ":before", ":after"GetPseudoValue,
NOT RECOMMENDED@Nonnull @CanIgnoreReturnValue SelenideElement selectRadio(java.lang.String value)
value - value of radio button to selectSelectRadio@CheckReturnValue @Nullable java.lang.String data(java.lang.String dataAttributeName)
GetDataAttribute,
NOT RECOMMENDED@Nullable @CheckReturnValue java.lang.String getAttribute(java.lang.String name)
getAttribute in interface org.openqa.selenium.WebElement@Nonnull @CheckReturnValue java.lang.String getCssValue(java.lang.String propertyName)
getCssValue in interface org.openqa.selenium.WebElement@CheckReturnValue boolean exists()
Exists,
NOT RECOMMENDED@CheckReturnValue boolean isDisplayed()
isDisplayed in interface org.openqa.selenium.WebElement@CheckReturnValue boolean is(Condition condition)
@CheckReturnValue boolean has(Condition condition)
@Nonnull @CanIgnoreReturnValue SelenideElement setSelected(boolean selected)
selected - true for checked and false for uncheckedSetSelected@Nonnull @CanIgnoreReturnValue SelenideElement should(Condition... condition)
Checks that given element meets all of given conditions.
IMPORTANT: If element does not match then conditions immediately, waits up to 4 seconds until element meets the conditions. It's extremely useful for dynamic content.
Timeout is configurable via Configuration.timeout
For example: $("#errorMessage").should(appear);
$("#errorMessage").should(appear).shouldBe(enabled);Config.timeout(),
Should@Nonnull @CanIgnoreReturnValue SelenideElement should(Condition condition, java.time.Duration timeout)
@Nonnull @CanIgnoreReturnValue SelenideElement shouldHave(Condition... condition)
Synonym for should(com.codeborne.selenide.Condition...). Useful for better readability.
For example: $("#errorMessage").shouldHave(text("Hello"), text("World"));
@Nonnull @CanIgnoreReturnValue SelenideElement shouldHave(Condition condition, java.time.Duration timeout)
@Nonnull @CanIgnoreReturnValue SelenideElement shouldBe(Condition... condition)
Synonym for should(com.codeborne.selenide.Condition...). Useful for better readability.
For example: $("#errorMessage").shouldBe(visible, enabled);
@Nonnull @CanIgnoreReturnValue SelenideElement shouldBe(Condition condition, java.time.Duration timeout)
@Nonnull @CanIgnoreReturnValue SelenideElement shouldNot(Condition... condition)
Checks that given element does not meet given conditions.
IMPORTANT: If element does match the conditions, waits up to 4 seconds until element does not meet the conditions. It's extremely useful for dynamic content.
Timeout is configurable via Configuration.timeout
For example: $("#errorMessage").should(exist);
Config.timeout(),
ShouldNot@Nonnull @CanIgnoreReturnValue SelenideElement shouldNot(Condition condition, java.time.Duration timeout)
@Nonnull @CanIgnoreReturnValue SelenideElement shouldNotHave(Condition... condition)
Synonym for shouldNot(com.codeborne.selenide.Condition...). Useful for better readability.
For example: $("#errorMessage").shouldNotHave(text("Exception"), text("Error"));
@Nonnull @CanIgnoreReturnValue SelenideElement shouldNotHave(Condition condition, java.time.Duration timeout)
@Nonnull @CanIgnoreReturnValue SelenideElement shouldNotBe(Condition... condition)
Synonym for shouldNot(com.codeborne.selenide.Condition...). Useful for better readability.
For example: $("#errorMessage").shouldNotBe(visible, enabled);
@Nonnull @CanIgnoreReturnValue SelenideElement shouldNotBe(Condition condition, java.time.Duration timeout)
@Nonnull @CanIgnoreReturnValue @Deprecated SelenideElement waitUntil(Condition condition, long timeoutMilliseconds)
shouldBe(Condition, Duration) or shouldHave(Condition, Duration)Wait until given element meets given conditions.
IMPORTANT: in most cases you don't need this method because all should- methods wait too. You need to use #waitUntil or #waitWhile methods only if you need another timeout.
condition - e.g. enabled, visible, text() and so ontimeoutMilliseconds - timeout in milliseconds.WaitUntil@Nonnull @CanIgnoreReturnValue @Deprecated SelenideElement waitUntil(Condition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)
shouldBe(Condition, Duration) or shouldHave(Condition, Duration)Wait until given element meets given conditions.
IMPORTANT: in most cases you don't need this method because all should- methods wait too. You need to use #waitUntil or #waitWhile methods only if you need another timeout.
condition - e.g. enabled, visible, text() and so ontimeoutMilliseconds - timeout in milliseconds.pollingIntervalMilliseconds - interval in milliseconds, when checking conditionWaitUntil@Nonnull @CanIgnoreReturnValue @Deprecated SelenideElement waitWhile(Condition condition, long timeoutMilliseconds)
shouldNotBe(Condition, Duration) or shouldNotHave(Condition, Duration)Wait until given element does not meet given conditions.
IMPORTANT: in most cases you don't need this method because all shouldNot- methods wait too. You need to use #waitUntil or #waitWhile methods only if you need another timeout.
condition - e.g. enabled, visible, text() and so ontimeoutMilliseconds - timeout in milliseconds.WaitWhile@Nonnull @CanIgnoreReturnValue @Deprecated SelenideElement waitWhile(Condition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)
shouldNotBe(Condition, Duration) or shouldNotHave(Condition, Duration)Wait until given element does not meet given conditions.
IMPORTANT: in most cases you don't need this method because all shouldNot- methods wait too. You need to use #waitUntil or #waitWhile methods only if you need another timeout.
condition - e.g. enabled, visible, text() and so ontimeoutMilliseconds - timeout in milliseconds.pollingIntervalMilliseconds - interval in milliseconds, when checking conditionWaitWhile@CheckReturnValue @Nonnull java.lang.String toString()
toString in class java.lang.ObjectToString@CheckReturnValue @Nonnull SelenideElement as(java.lang.String alias)
alias - a human-readable name of this element (null or empty string not allowed)@CheckReturnValue @Nonnull SelenideElement parent()
GetParent,
Lazy loading@CheckReturnValue @Nonnull SelenideElement sibling(int index)
index - the index of sibling elementGetSibling,
Lazy loading@CheckReturnValue @Nonnull SelenideElement preceding(int index)
index - the index of sibling elementGetPreceding,
Lazy loading@CheckReturnValue @Nonnull SelenideElement lastChild()
@CheckReturnValue @Nonnull SelenideElement closest(java.lang.String tagOrClass)
tagOrClass - Either HTML tag or CSS class. E.g. "form" or ".active".GetClosest,
Lazy loading@CheckReturnValue @Nonnull SelenideElement find(java.lang.String cssSelector)
Locates the first matching element inside given element
Short form of webElement.findElement(By.cssSelector(cssSelector))
Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement find(java.lang.String cssSelector, int index)
Locates the Nth matching element inside given element
Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement find(org.openqa.selenium.By selector)
find(String)Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement find(org.openqa.selenium.By selector, int index)
find(String, int)Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement $(java.lang.String cssSelector)
find(String)Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement $(java.lang.String cssSelector, int index)
find(String, int)Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement $(org.openqa.selenium.By selector)
find(String)Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement $(org.openqa.selenium.By selector, int index)
find(String, int)Find,
Lazy loading@CheckReturnValue @Nonnull SelenideElement $x(java.lang.String xpath)
Locates the first matching element inside given element using xpath locator
Short form of webElement.findElement(By.xpath(xpathLocator))
FindByXpath,
Lazy loading@CheckReturnValue @Nonnull SelenideElement $x(java.lang.String xpath, int index)
Locates the Nth matching element inside given element using xpath locator
FindByXpath,
Lazy loading@CheckReturnValue @Nonnull ElementsCollection findAll(java.lang.String cssSelector)
Short form of webDriver.findElements(thisElement, By.cssSelector(cssSelector))
For example, $("#multirowTable").findAll("tr.active").shouldHave(size(2));
FindAll,
Lazy loading@CheckReturnValue @Nonnull ElementsCollection findAll(org.openqa.selenium.By selector)
Short form of webDriver.findElements(thisElement, selector)
For example, $("#multirowTable").findAll(By.className("active")).shouldHave(size(2));
FindAll,
Lazy loading@CheckReturnValue @Nonnull ElementsCollection $$(java.lang.String cssSelector)
findAll(String)@CheckReturnValue @Nonnull ElementsCollection $$(org.openqa.selenium.By selector)
findAll(By)@CheckReturnValue @Nonnull ElementsCollection $$x(java.lang.String xpath)
Short form of webDriver.findElements(thisElement, By.xpath(xpath))
For example, $("#multirowTable").$$x("./input").shouldHave(size(2));
FindAllByXpath,
Lazy loading@Nonnull @CanIgnoreReturnValue java.io.File uploadFromClasspath(java.lang.String... fileName)
Upload file into file upload field. File is searched from classpath.
Multiple file upload is also supported. Just pass as many file names as you wish.
fileName - name of the file or the relative path in classpath e.g. "files/1.pfd"java.lang.IllegalArgumentException - if any of the files is not foundUploadFileFromClasspath@Nonnull @CanIgnoreReturnValue java.io.File uploadFile(java.io.File... file)
Upload file into file upload field.
Multiple file upload is also supported. Just pass as many files as you wish.
file - file object(s)java.lang.IllegalArgumentException - if any of the files is not found, or other errorsUploadFilevoid selectOption(int... index)
index - 0..N (0 means first option)SelectOptionByTextOrIndexvoid selectOption(java.lang.String... text)
text - visible text of optionSelectOptionByTextOrIndexvoid selectOptionContainingText(java.lang.String text)
text - substring of visible text of optionSelectOptionContainingTextvoid selectOptionByValue(java.lang.String... value)
value - "value" attribute of optionSelectOptionByValue@CheckReturnValue @Nonnull SelenideElement getSelectedOption() throws org.openqa.selenium.NoSuchElementException
org.openqa.selenium.NoSuchElementException - if no options are selectedGetSelectedOption,
NOT RECOMMENDED@CheckReturnValue @Nonnull ElementsCollection getSelectedOptions()
GetSelectedOptions,
NOT RECOMMENDED@CheckReturnValue @Nullable java.lang.String getSelectedValue()
GetSelectedValue,
NOT RECOMMENDED@CheckReturnValue @Nonnull java.lang.String getSelectedText()
GetSelectedText,
NOT RECOMMENDED@Nonnull @CanIgnoreReturnValue SelenideElement scrollTo()
ScrollTo@Nonnull @CanIgnoreReturnValue SelenideElement scrollIntoView(boolean alignToTop)
If alignToTop boolean value is true - the top of the element will be aligned to the top.
If alignToTop boolean value is false - the bottom of the element will be aligned to the bottom. Usage:
element.scrollIntoView(true);
// Corresponds to scrollIntoViewOptions: {block: "start", inline: "nearest"}
element.scrollIntoView(false);
// Corresponds to scrollIntoViewOptions: {block: "end", inline: "nearest"}
alignToTop - boolean value that indicate how element will be aligned to the visible area of the scrollable ancestor.ScrollIntoView,
Web API reference@Nonnull @CanIgnoreReturnValue SelenideElement scrollIntoView(java.lang.String scrollIntoViewOptions)
scrollIntoViewOptions:
* behavior (optional) - Defines the transition animation
1. auto (default)
2. instant
3. smooth
* block (optional)
1. start
2. center (default)
3. end
4. nearest
* inline
1. start
2. center
3. end
4. nearest (default)
Usage:
element.scrollIntoView("{block: \"end\"}");
element.scrollIntoView("{behavior: \"instant\", block: \"end\", inline: \"nearest\"}");
scrollIntoViewOptions - is an object with the align properties: behavior, block and inline.ScrollIntoView,
Web API reference@CheckReturnValue
@Nonnull
java.io.File download()
throws java.io.FileNotFoundException
@{@link Config#fileDownload() }.java.lang.RuntimeException - if 50x status code was returned from serverjava.io.FileNotFoundException - if 40x status code was returned from serverFileDownloadMode,
DownloadFile@CheckReturnValue
@Nonnull
java.io.File download(long timeout)
throws java.io.FileNotFoundException
@{@link Config#fileDownload() }.timeout - download operations timeout.java.lang.RuntimeException - if 50x status code was returned from serverjava.io.FileNotFoundException - if 40x status code was returned from serverDownloadFile@CheckReturnValue @Nonnull java.io.File download(FileFilter fileFilter) throws java.io.FileNotFoundException
@{@link Config#fileDownload() }.fileFilter - Criteria for defining which file is expected (
FileFilters.withName(String),
FileFilters.withNameMatching(String),
FileFilters.withName(String)
).java.lang.RuntimeException - if 50x status code was returned from serverjava.io.FileNotFoundException - if 40x status code was returned from server, or the downloaded file didn't match given filter.FileFilters,
DownloadFile@CheckReturnValue
@Nonnull
java.io.File download(long timeout,
FileFilter fileFilter)
throws java.io.FileNotFoundException
@{@link Config#fileDownload() }.timeout - download operations timeout.fileFilter - Criteria for defining which file is expected (
FileFilters.withName(String),
FileFilters.withNameMatching(String),
FileFilters.withName(String)
).java.lang.RuntimeException - if 50x status code was returned from serverjava.io.FileNotFoundException - if 40x status code was returned from server, or the downloaded file didn't match given filter.FileFilters,
DownloadFile@CheckReturnValue @Nonnull java.io.File download(DownloadOptions options) throws java.io.FileNotFoundException
java.io.FileNotFoundException@CheckReturnValue @Nonnull java.lang.String getSearchCriteria()
GetSearchCriteria@CheckReturnValue @Nonnull org.openqa.selenium.WebElement toWebElement()
WebElement wrapped by this objectorg.openqa.selenium.NoSuchElementException - if element does not exist (without waiting for the element)ToWebElement@CheckReturnValue @Nonnull org.openqa.selenium.WebElement getWrappedElement()
getWrappedElement in interface org.openqa.selenium.WrapsElementWebElementElementNotFound - if element does not exist (after waiting for N seconds)GetWrappedElementvoid click(ClickOptions clickOption)
ClickOptions: $("#username").click(ClickOptions.usingJavaScript())
You can specify a relative offset from the center of the element inside ClickOptions:
e.g. $("#username").click(usingJavaScript().offset(123, 222))
Clickvoid click()
By default it uses default Selenium method click.
But it uses JavaScript method to click if com.codeborne.selenide.Configuration#clickViaJs is defined.
It may be helpful for testing in Internet Explorer where native click doesn't always work correctly.
click in interface org.openqa.selenium.WebElementClick@Deprecated
void click(int offsetX,
int offsetY)
click(ClickOptions) with offsets@Nonnull @CanIgnoreReturnValue SelenideElement contextClick()
ContextClick@Nonnull @CanIgnoreReturnValue SelenideElement doubleClick()
DoubleClick@Nonnull @CanIgnoreReturnValue SelenideElement hover()
Hover@Nonnull @CanIgnoreReturnValue SelenideElement hover(HoverOptions options)
options - optional hover parameters (offset etc)Hover@Nonnull @CanIgnoreReturnValue SelenideElement dragAndDropTo(java.lang.String targetCssSelector)
Before dropping, waits until target element gets visible.
targetCssSelector - CSS selector defining target elementDragAndDropTo@Nonnull @CanIgnoreReturnValue SelenideElement dragAndDropTo(org.openqa.selenium.WebElement target)
Before dropping, waits until target element gets visible.
target - target elementDragAndDropTo@Nonnull @CanIgnoreReturnValue SelenideElement dragAndDropTo(java.lang.String targetCssSelector, DragAndDropOptions options)
Before dropping, waits until target element gets visible.
targetCssSelector - target css selectoroptions - drag and drop options to define which way it will be executedDragAndDropTo<ReturnType> ReturnType execute(Command<ReturnType> command)
Command.execute(SelenideElement, WebElementSource, Object[])
when executed).<ReturnType> ReturnType execute(Command<ReturnType> command, java.time.Duration timeout)
Command.execute(SelenideElement, WebElementSource, Object[])
when executed).boolean isImage()
java.lang.IllegalArgumentException - if argument is not an "img" elementIsImage,
NOT RECOMMENDED@CheckReturnValue @Nullable java.io.File screenshot()
TakeScreenshot@CheckReturnValue @Nullable java.awt.image.BufferedImage screenshotAsImage()
TakeScreenshotAsImage