public interface SelenideElement
extends org.openqa.selenium.WebElement, org.openqa.selenium.internal.FindsByLinkText, org.openqa.selenium.internal.FindsById, org.openqa.selenium.internal.FindsByName, org.openqa.selenium.internal.FindsByTagName, org.openqa.selenium.internal.FindsByClassName, org.openqa.selenium.internal.FindsByCssSelector, org.openqa.selenium.internal.FindsByXPath, org.openqa.selenium.internal.WrapsDriver, org.openqa.selenium.internal.WrapsElement, org.openqa.selenium.internal.Locatable
WebElement
with additional methods like
shouldBe(Condition...)
and shouldHave(Condition...)
Modifier and Type | Method and Description |
---|---|
SelenideElement |
$(org.openqa.selenium.By selector)
com.codeborne.selenide.SelenideElement#find(java.lang.String)
|
SelenideElement |
$(org.openqa.selenium.By selector,
int index)
com.codeborne.selenide.SelenideElement#find(java.lang.String)
|
SelenideElement |
$(java.lang.String cssSelector) |
SelenideElement |
$(java.lang.String cssSelector,
int index)
com.codeborne.selenide.SelenideElement#find(java.lang.String)
|
ElementsCollection |
$$(org.openqa.selenium.By selector)
com.codeborne.selenide.SelenideElement#findAll(java.lang.String)
|
ElementsCollection |
$$(java.lang.String cssSelector)
com.codeborne.selenide.SelenideElement#findAll(java.lang.String)
|
SelenideElement |
append(java.lang.String text)
Append given test to the text field and trigger "change" event.
|
java.lang.String |
attr(java.lang.String attributeName)
Get the attribute of the element.
|
void |
click()
Click the element
|
SelenideElement |
closest(java.lang.String tagOrClass)
Find closes ancestor element matching given criteria.
|
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 linked by "href" attribute of this element
|
SelenideElement |
dragAndDropTo(java.lang.String targetCssSelector)
Drag and drop this element to the target.
|
boolean |
exists()
Checks if element exists true on the current page.
|
SelenideElement |
find(org.openqa.selenium.By selector)
com.codeborne.selenide.SelenideElement#find(java.lang.String)
|
SelenideElement |
find(org.openqa.selenium.By selector,
int index)
com.codeborne.selenide.SelenideElement#find(java.lang.String)
|
SelenideElement |
find(java.lang.String cssSelector)
Find the first matching element inside given element
|
SelenideElement |
find(java.lang.String cssSelector,
int index)
Find 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)) |
void |
followLink()
Actual for <a href> elements.
|
SelenideElement |
getSelectedOption()
Find selected option 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.
|
org.openqa.selenium.WebElement |
getWrappedElement() |
boolean |
has(Condition condition)
Return true iff element matches given condition
|
SelenideElement |
hover()
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)
Return true iff element matches given condition
|
boolean |
isDisplayed()
Check if this element exists and visible.
|
boolean |
isImage()
Check if image is properly loaded.
|
java.lang.String |
name()
Get the "name" attribute of the element
|
SelenideElement |
parent()
Get parent element of this element
For example, $("td").parent() could give some "tr".
|
SelenideElement |
pressEnter()
Press ENTER.
|
SelenideElement |
pressEscape()
Press ESCAPE.
|
SelenideElement |
pressTab()
Press TAB.
|
java.io.File |
screenshot()
Take screenshot of this element
|
SelenideElement |
scrollTo()
Ask browser to scroll to this element
|
void |
selectOption(java.lang.String text)
Select an option from dropdown list
|
void |
selectOptionByValue(java.lang.String value)
Select an option by value from dropdown list
|
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)
Clear the text field, enter given text and trigger "change" event.
|
SelenideElement |
should(Condition... condition)
Checks that given element meets all of given conditions.
|
SelenideElement |
should(java.lang.String message,
Condition... condition)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
SelenideElement |
shouldBe(Condition... condition)
Synonym for #should.
|
SelenideElement |
shouldBe(java.lang.String message,
Condition... condition)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
SelenideElement |
shouldHave(Condition... condition)
Synonym for #should.
|
SelenideElement |
shouldHave(java.lang.String message,
Condition... condition)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
SelenideElement |
shouldNot(Condition... condition)
Checks that given element does not meet given conditions.
|
SelenideElement |
shouldNot(java.lang.String message,
Condition... condition)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
SelenideElement |
shouldNotBe(Condition... condition)
Synonym for #shouldNot.
|
SelenideElement |
shouldNotBe(java.lang.String message,
Condition... condition)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
SelenideElement |
shouldNotHave(Condition... condition)
Synonym for #shouldNot.
|
SelenideElement |
shouldNotHave(java.lang.String message,
Condition... condition)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
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
|
SelenideElement |
val(java.lang.String text)
Same as #setValue(java.lang.String)
|
SelenideElement |
waitUntil(Condition condition,
long timeoutMilliseconds)
Wait until given element meets given conditions.
|
SelenideElement |
waitUntil(java.lang.String message,
Condition condition,
long timeoutMilliseconds)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
SelenideElement |
waitWhile(Condition condition,
long timeoutMilliseconds)
Wait until given element does not meet given conditions.
|
SelenideElement |
waitWhile(java.lang.String message,
Condition condition,
long timeoutMilliseconds)
Deprecated.
Method with "message" parameter will be removed in Selenide 3.0
Use method com.codeborne.selenide.Condition#because instead
|
clear, findElement, findElements, getAttribute, getCssValue, getLocation, getSize, getTagName, isEnabled, isSelected, sendKeys, submit
findElementByLinkText, findElementByPartialLinkText, findElementsByLinkText, findElementsByPartialLinkText
findElementById, findElementsById
findElementByName, findElementsByName
findElementByTagName, findElementsByTagName
findElementByClassName, findElementsByClassName
findElementByCssSelector, findElementsByCssSelector
void followLink()
Actual for <a href> elements. Navigates browser by clicking this link.
In some situations just clicking is not enough: $.click() doesn't take effect for <a href>. In these cases use #followLink that actually navigates browser to @href value.
SelenideElement setValue(java.lang.String text)
Clear the text field, enter given text and trigger "change" event.
Implementation details: this is the same as
1. WebElement.clear() 2. WebElement.sendKeys(text) 3. Trigger change event
text
- Any text to enter into the text field.SelenideElement val(java.lang.String text)
SelenideElement append(java.lang.String text)
Append given test to the text field and trigger "change" event.
Implementation details: This is the same as
1. WebElement.sendKeys(text) 2. Trigger change event
text
- Any text to append into the text field.SelenideElement pressEnter()
$("query").val("Aikido techniques").pressEnter();Implementation details: This is the same as
WebElement.sendKeys(Keys.ENTER)
SelenideElement pressTab()
$("#to").val("[email protected]").pressTab();Implementation details: This is the same as
WebElement.sendKeys(Keys.TAB)
SelenideElement pressEscape()
$(".edit").click().pressEscape();Implementation details: This is the same as
WebElement.sendKeys(Keys.ESCAPE)
java.lang.String getText()
getText
in interface org.openqa.selenium.WebElement
java.lang.String text()
WebElement.getText()
java.lang.String innerText()
java.lang.String innerHtml()
java.lang.String attr(java.lang.String attributeName)
java.lang.String name()
java.lang.String val()
SelenideElement selectRadio(java.lang.String value)
value
- value of radio button to selectjava.lang.String data(java.lang.String dataAttributeName)
boolean exists()
boolean isDisplayed()
isDisplayed
in interface org.openqa.selenium.WebElement
boolean is(Condition condition)
boolean has(Condition condition)
SelenideElement setSelected(boolean selected)
selected
- true for checked and false for uncheckedSelenideElement 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);
Configuration.timeout
@Deprecated SelenideElement should(java.lang.String message, Condition... condition)
SelenideElement shouldHave(Condition... condition)
Synonym for #should. Useful for better readability.
For example:
$("#errorMessage").shouldHave(text("Hello"), text("World"));
@Deprecated SelenideElement shouldHave(java.lang.String message, Condition... condition)
SelenideElement shouldBe(Condition... condition)
Synonym for #should. Useful for better readability.
For example:
$("#errorMessage").shouldBe(visible, enabled);
@Deprecated SelenideElement shouldBe(java.lang.String message, Condition... condition)
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);
Configuration.timeout
@Deprecated SelenideElement shouldNot(java.lang.String message, Condition... condition)
SelenideElement shouldNotHave(Condition... condition)
Synonym for #shouldNot. Useful for better readability.
For example:
$("#errorMessage").shouldNotHave(text("Exception"), text("Error"));
@Deprecated SelenideElement shouldNotHave(java.lang.String message, Condition... condition)
SelenideElement shouldNotBe(Condition... condition)
Synonym for #shouldNot. Useful for better readability.
For example:
$("#errorMessage").shouldNotBe(visible, enabled);
@Deprecated SelenideElement shouldNotBe(java.lang.String message, Condition... condition)
SelenideElement waitUntil(Condition condition, long timeoutMilliseconds)
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 #waitFor methods only if you need another timeout.
condition
- e.g. enabled, visible, text() and so ontimeoutMilliseconds
- timeout in milliseconds.@Deprecated SelenideElement waitUntil(java.lang.String message, Condition condition, long timeoutMilliseconds)
SelenideElement waitWhile(Condition condition, long timeoutMilliseconds)
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 #waitFor methods only if you need another timeout.
condition
- e.g. enabled, visible, text() and so ontimeoutMilliseconds
- timeout in milliseconds.@Deprecated SelenideElement waitWhile(java.lang.String message, Condition condition, long timeoutMilliseconds)
java.lang.String toString()
toString
in class java.lang.Object
SelenideElement parent()
SelenideElement closest(java.lang.String tagOrClass)
tagOrClass
- Either HTML tag or CSS class. E.g. "form" or ".active".SelenideElement find(java.lang.String cssSelector)
Find the first matching element inside given element
Short form of webElement.findElement(By.cssSelector(cssSelector))
SelenideElement find(java.lang.String cssSelector, int index)
Find the Nth matching element inside given element
SelenideElement find(org.openqa.selenium.By selector)
SelenideElement find(org.openqa.selenium.By selector, int index)
SelenideElement $(java.lang.String cssSelector)
find(java.lang.String)
SelenideElement $(java.lang.String cssSelector, int index)
SelenideElement $(org.openqa.selenium.By selector)
SelenideElement $(org.openqa.selenium.By selector, int index)
ElementsCollection findAll(java.lang.String cssSelector)
Short form of webDriver.findElements(thisElement, By.cssSelector(cssSelector))
For example, $("#multirowTable").findAll("tr.active").shouldHave(size(2));
ElementsCollection findAll(org.openqa.selenium.By selector)
Short form of webDriver.findElements(thisElement, selector)
For example, $("#multirowTable").findAll(By.className("active")).shouldHave(size(2));
ElementsCollection $$(java.lang.String cssSelector)
ElementsCollection $$(org.openqa.selenium.By selector)
java.io.File uploadFromClasspath(java.lang.String... fileName)
Upload file into file upload field. File is searched from classpath.
Short form of webElement.sendKeys("c:/files/my-file.txt");
Multiple file upload is also supported. Just pass as many file names as you wish.
java.io.File uploadFile(java.io.File... file)
Upload file into file upload field.
Short form of webElement.sendKeys("c:/files/my-file.txt");
Multiple file upload is also supported. Just pass as many files as you wish.
void selectOption(java.lang.String text)
text
- visible text of optionvoid selectOptionByValue(java.lang.String value)
value
- "value" attribute of optionSelenideElement getSelectedOption()
org.openqa.selenium.NoSuchElementException
- if no options are selectedjava.lang.String getSelectedValue()
java.lang.String getSelectedText()
SelenideElement scrollTo()
java.io.File download() throws java.io.FileNotFoundException
java.lang.RuntimeException
- if 50x status code was returned from serverjava.io.FileNotFoundException
- if 40x status code was returned from serverorg.openqa.selenium.WebElement toWebElement()
org.openqa.selenium.WebElement getWrappedElement()
getWrappedElement
in interface org.openqa.selenium.internal.WrapsElement
void 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.WebElement
SelenideElement contextClick()
SelenideElement doubleClick()
SelenideElement hover()
SelenideElement dragAndDropTo(java.lang.String targetCssSelector)
targetCssSelector
- CSS selector defining target element.boolean isImage()
java.lang.IllegalArgumentException
- if argument is not an "img" elementjava.io.File screenshot()