public class UiElement extends Object implements org.openqa.selenium.WebElement, org.openqa.selenium.internal.WrapsElement, org.openqa.selenium.internal.Locatable, org.openqa.selenium.internal.HasIdentity
WebElement
and provides new functionality.
$("#errorMessage").shouldBe(visible, enabled).click();
$("td").parent().doubleClick();
$(".edit").pressBackSpace();
Modifier and Type | Method and Description |
---|---|
UiElement |
$(org.openqa.selenium.By selector)
Driver Type: Desktop, Web
|
UiElement |
$(org.openqa.selenium.By selector,
int index)
Driver Type: Desktop, Web
|
UiElement |
$(String cssSelector)
Driver Type: Desktop, Web
|
UiElement |
$(String cssSelector,
int index)
Driver Type: Desktop, Web
|
UiElementCollection |
$$(org.openqa.selenium.By selector)
Driver Type: Desktop, Web
|
UiElementCollection |
$$(String cssSelector)
Driver Type: Desktop, Web
|
UiElement |
append(Object text)
Append given text to the text field.
|
String |
attr(String attributeName)
Get the attribute of the element.
|
int |
bottom() |
int |
centerX() |
int |
centerY() |
void |
clear() |
void |
click()
Click the element
|
UiElement |
click(int clicks)
Click the element number of times
|
void |
click(int offsetX,
int offsetY)
Click the element with offset
Offset is calculated from TOP LEFT corner
|
UiElement |
click(int clicks,
int offsetX,
int offsetY)
Click the element number of times
|
UiElement |
closest(String tagOrClass)
Find closes ancestor element matching given criteria.
|
UiElement |
contextClick()
Click with right mouse button on this element
|
UiElement |
contextClick(int offsetX,
int offsetY)
Click with right mouse button by offset on this element
|
String |
copySelectedText()
Copies selected text
|
UiElement |
doubleClick()
Double click the element
|
UiElement |
doubleClick(int offsetX,
int offsetY)
Double click the element
|
boolean |
equals(Object o) |
UiElement |
find(org.openqa.selenium.By selector)
Find the first matching element inside given element
|
UiElement |
find(org.openqa.selenium.By selector,
int index)
Find the Nth matching element inside given element
|
UiElement |
find(String cssSelector)
Find the first matching element inside given element
|
UiElement |
find(String cssSelector,
int index)
Find the Nth matching element inside given element
|
UiElementCollection |
findAll(org.openqa.selenium.By selector)
Short form of
webDriver.findElements(thisElement, selector) |
UiElementCollection |
findAll(String cssSelector)
Short form of
webDriver.findElements(thisElement, By.cssSelector(cssSelector)) |
org.openqa.selenium.WebElement |
findElement(org.openqa.selenium.By by) |
List<org.openqa.selenium.WebElement> |
findElements(org.openqa.selenium.By by) |
boolean |
focus() |
String |
getAttribute(String s) |
org.openqa.selenium.interactions.internal.Coordinates |
getCoordinates() |
String |
getCssValue(String s) |
String |
getId() |
org.openqa.selenium.Point |
getLocation() |
org.openqa.selenium.Rectangle |
getRect() |
<X> X |
getScreenshotAs(org.openqa.selenium.OutputType<X> outputType) |
UiElement |
getSelectedOption()
Find selected option from this select field
|
String |
getSelectedText()
Get text of selected option in select field
|
String |
getSelectedValue()
Get value of selected option in select field
|
org.openqa.selenium.Dimension |
getSize() |
String |
getTagName() |
String |
getText()
Get the visible text of this element
|
String |
getValue()
Get the "value" attribute of the element
|
org.openqa.selenium.WebElement |
getWrappedElement() |
boolean |
has(UiCondition condition)
Return true iff element matches given condition
|
int |
hashCode() |
UiElement |
hover()
Emulate "mouseOver" event.
|
String |
innerHtml()
Get the HTML code of the element with children.
|
String |
innerText()
Get the text code of the element with children.
|
boolean |
is(UiCondition condition)
Return true if element matches given condition
|
boolean |
isDisplayed() |
boolean |
isEnabled() |
boolean |
isExists()
Deprecated.
from 9.2, it will be delete in 10.0
|
boolean |
isImageLoaded()
Check if image is properly loaded.
|
boolean |
isSelected() |
int |
left() |
String |
name()
Get the "name" attribute of the element
|
UiElement |
parent()
Get parent element of this element
For example, $("td").parent() could give some "tr".
|
UiElement |
pressBackSpace()
Press BACK_SPACE.
|
UiElement |
pressCtrlA()
Send CTRL+A.
|
UiElement |
pressCtrlC()
Send CTRL+C.
|
UiElement |
pressCtrlShiftZ()
Send CTRL+SHIFT+Z.
|
UiElement |
pressCtrlV()
Send CTRL+V.
|
UiElement |
pressCtrlX()
Send CTRL+X.
|
UiElement |
pressCtrlZ()
Send CTRL+Z.
|
UiElement |
pressEnter()
Press ENTER.
|
UiElement |
pressEscape()
Press ESCAPE.
|
UiElement |
pressSpace()
Press SPACE.
|
UiElement |
pressTab()
Press TAB.
|
int |
right() |
UiElement |
scrollDown(int times)
Moves mouse cursor to the center of element and scrolls down number of times.
|
UiElement |
scrollTo()
Ask browser to scroll to this element
|
UiElement |
scrollUp(int times)
Moves mouse cursor to the center of element and scrolls up number of times.
|
String |
selectAllTextAndCopy()
Sample: String selectedText = $("[CLASS:Edit; INSTANCE:1]")
.append("some text")
.selectAllTextAndCopy();
|
UiElement |
selectOption(int index)
Select an option from dropdown list (by index)
|
UiElement |
selectOption(String text)
Select an option from dropdown list (by text)
|
UiElement |
selectOptionByValue(String value)
Select an option from dropdown list (by value)
|
void |
sendKeys(CharSequence... charSequences) |
UiElement |
sendKeys(Object text) |
UiElement |
setSelected(boolean selected)
Set checkbox/radio state to CHECKED or UNCHECKED.
|
UiElement |
setText(Object text)
Sets given text to a text field
|
UiElement |
setValue(Object text)
Clear the text field and enter given text.
|
UiElement |
should(UiCondition... conditions) |
UiElement |
should(UiCondition condition)
Checks that given element meets all of given conditions.
|
UiElement |
should(UiCondition condition1,
UiCondition condition2) |
UiElement |
shouldBe(UiCondition... conditions)
Synonym for
should(UiCondition...) }. |
UiElement |
shouldBe(UiCondition condition) |
UiElement |
shouldHave(UiCondition... conditions)
Synonym for
should(UiCondition...) }. |
UiElement |
shouldHave(UiCondition condition) |
UiElement |
shouldNot(UiCondition... conditions)
Checks that given element does not meet given conditions.
|
UiElement |
shouldNot(UiCondition condition) |
UiElement |
shouldNotBe(UiCondition... conditions)
Synonym for
shouldNot(UiCondition...) . |
UiElement |
shouldNotBe(UiCondition condition) |
UiElement |
shouldNotHave(UiCondition... conditions)
Synonym for
shouldNot(UiCondition...) . |
UiElement |
shouldNotHave(UiCondition condition) |
UiElement |
singleClick()
Single click the element.
|
UiElement |
singleClick(int offsetX,
int offsetY)
Single click the element.
|
boolean |
stillExists()
Checks if element still exists on the current page.
|
void |
submit() |
String |
text()
Short form of getText()
|
UiElement |
text(Object text)
Driver Type: Desktop, Web
|
int |
top() |
org.openqa.selenium.support.ui.Select |
toSelectElement()
Converts UI element to
Select |
String |
toString()
Displays WebElement in human-readable format.
|
org.openqa.selenium.WebElement |
toWebElement() |
UiElement |
tripleClick()
Triple click the element
|
UiElement |
tripleClick(int offsetX,
int offsetY)
Triple click the element
|
String |
val()
Get the "value" attribute of the element
Same as #getValue()
|
UiElement |
val(Object text)
Driver Type: Desktop, Web
|
UiElement |
waitUntil(UiCondition condition)
Wait until given element meets given conditions.
|
UiElement |
waitUntil(UiCondition condition,
long timeoutMilliseconds)
Wait until given element meets given conditions.
|
UiElement |
waitUntil(UiCondition condition,
long timeoutMilliseconds,
long pollingIntervalMilliseconds)
Wait until given element meets given conditions.
|
UiElement |
waitWhile(UiCondition condition)
Wait while given element meets given conditions.
|
UiElement |
waitWhile(UiCondition condition,
long timeoutMilliseconds)
Wait while given element meets given conditions.
|
UiElement |
waitWhile(UiCondition condition,
long timeoutMilliseconds,
long pollingIntervalMilliseconds)
Wait while given element meets given conditions.
|
UiElement |
wheelClick()
Wheel click on the element
|
UiElement |
wheelClick(int offsetX,
int offsetY)
Wheel click on the element
|
public UiElement append(Object text)
Append given text to the text field.
This is the same as WebElement.sendKeys(text)
Driver Type: Desktop, Web
text
- Any text to append into the text field.public UiElement setValue(Object text)
Clear the text field and enter given text.
Implementation details: this is the same as
1. WebElement.clear() 2. WebElement.sendKeys(text)
Driver Type: Desktop, Web
text
- Any text to enter into the text field.public UiElement text(Object text)
Driver Type: Desktop, Web
Same as #setValue(java.lang.String)public UiElement setText(Object text)
Sets given text to a text field
Driver Type: Desktop
text
- Any text to enter into the text field.public UiElement pressEnter()
$("query").val("Aikido techniques").pressEnter();Implementation details: This is the same as
WebElement.sendKeys(Keys.ENTER)
Driver Type: Desktop, Web
public UiElement pressTab()
$("#to").val("stiven@seagal.com").pressTab();Implementation details: This is the same as
WebElement.sendKeys(Keys.TAB)
Driver Type: Desktop, Web
public UiElement pressEscape()
$(".edit").click().pressEscape();Implementation details: This is the same as
WebElement.sendKeys(Keys.ESCAPE)
Driver Type: Desktop, Web
public UiElement pressSpace()
$(".edit").pressSpace();Implementation details: This is the same as
WebElement.sendKeys(Keys.SPACE)
Driver Type: Desktop, Web
public UiElement pressBackSpace()
$(".edit").pressBackSpace();Implementation details: This is the same as
WebElement.sendKeys(Keys.BACK_SPACE)
Driver Type: Desktop, Web
public UiElement pressCtrlA()
$(".edit").pressCtrlA();Implementation details: This is the same as
WebElement.sendKeys.sendKeys(Keys.chord(Keys.CONTROL, "a"))
Driver Type: Desktop, Web
public UiElement pressCtrlC()
$(".edit").pressCtrlC();Implementation details: This is the same as
WebElement.sendKeys.sendKeys(Keys.chord(Keys.CONTROL, "c"))
Driver Type: Desktop, Web
public UiElement pressCtrlV()
$(".edit").pressCtrlV();Implementation details: This is the same as
WebElement.sendKeys(Keys.chord(Keys.CONTROL, "v"))
Driver Type: Desktop, Web
public UiElement pressCtrlX()
$(".edit").pressCtrlX();Implementation details: This is the same as
WebElement.sendKeys(Keys.chord(Keys.CONTROL, "x"))
Driver Type: Desktop, Web
public UiElement pressCtrlZ()
$(".edit").pressCtrlZ();Implementation details: This is the same as
WebElement.sendKeys(Keys.chord(Keys.CONTROL, "z"))
Driver Type: Desktop, Web
public UiElement pressCtrlShiftZ()
$(".edit").pressCtrlShiftZ();Implementation details: This is the same as
WebElement.sendKeys(Keys.chord(Keys.CONTROL, Keys.SHIFT, "z"))
Driver Type: Desktop, Web
public String getText()
Driver Type: Desktop, Web
getText
in interface org.openqa.selenium.WebElement
public String text()
Driver Type: Desktop, Web
WebElement.getText()
public String innerText()
Driver Type: Web
Short form of getAttribute("textContent") or getAttribute("innerText") depending on browser.public String innerHtml()
Driver Type: Web
public String attr(String attributeName)
Driver Type: Desktop, Web
public String name()
Driver Type: Desktop, Web
public String val()
Driver Type: Desktop, Web
public String getValue()
Driver Type: Desktop, Web
@Deprecated public boolean isExists()
Driver Type: Desktop, Web
public boolean stillExists()
Driver Type: Desktop, Web
public boolean is(UiCondition condition)
Driver Type: Desktop, Web
public boolean has(UiCondition condition)
Driver Type: Desktop, Web
public UiElement should(UiCondition condition)
Checks that given element meets all of given conditions.
IMPORTANT: Element matches these conditions immediately.
For example:
$("#errorMessage").should(APPEAR);
Driver Type: Desktop, Web
$("#errorMessage").should(APPEAR).shouldBe(ENABLED);
IllegalStateException
- if element is not matched to conditionpublic UiElement should(UiCondition... conditions)
public UiElement should(UiCondition condition1, UiCondition condition2)
public UiElement shouldHave(UiCondition... conditions)
Synonym for should(UiCondition...)
}. Useful for better readability.
For example:
$("#errorMessage").shouldHave(text("Hello"), text("World"));
Driver Type: Desktop, Web
should(UiCondition...)
public UiElement shouldHave(UiCondition condition)
public UiElement shouldBe(UiCondition... conditions)
Synonym for should(UiCondition...)
}. Useful for better readability.
For example:
$("#errorMessage").shouldBe(visible, enabled);
Driver Type: Desktop, Web
should(UiCondition...)
public UiElement shouldBe(UiCondition condition)
public UiElement shouldNot(UiCondition... conditions)
Checks that given element does not meet given conditions.
IMPORTANT: If element matches these conditions immediately.
For example:
$("#errorMessage").should(exist);
Driver Type: Desktop, Web
public UiElement shouldNot(UiCondition condition)
public UiElement shouldNotHave(UiCondition... conditions)
Synonym for shouldNot(UiCondition...)
. Useful for better readability.
For example:
$("#errorMessage").shouldNotHave(text("Exception"), text("Error"));
Driver Type: Desktop, Web
shouldNot(UiCondition...)
public UiElement shouldNotHave(UiCondition condition)
public UiElement shouldNotBe(UiCondition... conditions)
Synonym for shouldNot(UiCondition...)
. Useful for better readability.
For example:
$("#errorMessage").shouldNotBe(visible, enabled);
Driver Type: Desktop, Web
shouldNot(UiCondition...)
public UiElement shouldNotBe(UiCondition condition)
public UiElement waitUntil(UiCondition condition)
Wait until given element meets given conditions.
Driver Type: Desktop, Web
condition
- e.g. enabled, visible, text() and so onIllegalStateException
- if element still is not matched to condition after the timeoutpublic UiElement waitUntil(UiCondition condition, long timeoutMilliseconds)
Wait until given element meets given conditions.
Driver Type: Desktop, Web
condition
- e.g. enabled, visible, text() and so ontimeoutMilliseconds
- timeout in milliseconds.IllegalStateException
- if element still is not matched to condition after the timeoutpublic UiElement waitUntil(UiCondition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)
Wait until given element meets given conditions.
Driver Type: Desktop, Web
condition
- e.g. enabled, visible, text() and so ontimeoutMilliseconds
- timeout in milliseconds.pollingIntervalMilliseconds
- interval in milliseconds, when checking conditionIllegalStateException
- if element still is not matched to condition after the timeoutpublic UiElement waitWhile(UiCondition condition)
Wait while given element meets given conditions.
Driver Type: Desktop, Web
condition
- e.g. enabled, visible, text() and so onIllegalStateException
- if element still is not matched to condition after the timeoutpublic UiElement waitWhile(UiCondition condition, long timeoutMilliseconds)
Wait while given element meets given conditions.
Driver Type: Desktop, Web
condition
- e.g. enabled, visible, text() and so ontimeoutMilliseconds
- timeout in milliseconds.IllegalStateException
- if element still is not matched to condition after the timeoutpublic UiElement waitWhile(UiCondition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)
Wait while given element meets given conditions.
Driver Type: Desktop, Web
condition
- e.g. enabled, visible, text() and so ontimeoutMilliseconds
- timeout in milliseconds.pollingIntervalMilliseconds
- interval in milliseconds, when checking conditionIllegalStateException
- if element still is not matched to condition after the timeoutpublic UiElement parent()
Driver Type: Web
public UiElement closest(String tagOrClass)
Driver Type: Web
tagOrClass
- Either HTML tag or CSS class. E.g. "form" or ".active".public UiElement find(String cssSelector)
Find the first matching element inside given element
Short form of webElement.findElement(By.cssSelector(cssSelector))
Driver Type: Desktop, Web
public UiElement find(String cssSelector, int index)
Find the Nth matching element inside given element
Driver Type: Desktop, Web
public UiElement find(org.openqa.selenium.By selector)
Find the first matching element inside given element
Short form of webElement.findElement(By.cssSelector(cssSelector))
Driver Type: Desktop, Web
public UiElement find(org.openqa.selenium.By selector, int index)
Find the Nth matching element inside given element
Driver Type: Desktop, Web
public UiElement $(String cssSelector)
Driver Type: Desktop, Web
find(java.lang.String)
public UiElement $(String cssSelector, int index)
Driver Type: Desktop, Web
UiElement#find(java.lang.String)public UiElement $(org.openqa.selenium.By selector)
Driver Type: Desktop, Web
UiElement#find(java.lang.String)public UiElement $(org.openqa.selenium.By selector, int index)
Driver Type: Desktop, Web
UiElement#find(java.lang.String)public UiElementCollection findAll(String cssSelector)
Short form of webDriver.findElements(thisElement, By.cssSelector(cssSelector))
For example, $("#multirowTable").findAll("tr.active").shouldHave(size(2));
Driver Type: Desktop, Web
public UiElementCollection findAll(org.openqa.selenium.By selector)
Short form of webDriver.findElements(thisElement, selector)
For example, $("#multirowTable").findAll(By.className("active")).shouldHave(size(2));
Driver Type: Desktop, Web
public UiElementCollection $$(String cssSelector)
Driver Type: Desktop, Web
UiElement#findAll(java.lang.String)public UiElementCollection $$(org.openqa.selenium.By selector)
Driver Type: Desktop, Web
UiElement#findAll(java.lang.String)public UiElement setSelected(boolean selected)
Driver Type: Desktop, Web
selected
- true for checked and false for uncheckedpublic org.openqa.selenium.support.ui.Select toSelectElement()
Select
Driver Type: Web
Select
object that Models a SELECT tag, providing helper methods to select and deselect options.public UiElement selectOption(int index)
Driver Type: Web
index
- 0..N (0 means first option)public UiElement selectOption(String text)
Driver Type: Web
text
- visible text of optionpublic UiElement selectOptionByValue(String value)
Driver Type: Web
value
- "value" attribute of optionpublic UiElement getSelectedOption()
Driver Type: Web
public String getSelectedValue()
Driver Type: Web
public String getSelectedText()
Driver Type: Web
public UiElement scrollTo()
Driver Type: Web
public UiElement scrollDown(int times)
Driver Type: Desktop
times
- how many times need to scroll (ticks of the mouse wheel)public UiElement scrollUp(int times)
Driver Type: Desktop
times
- how many times need to scroll (ticks of the mouse wheel)public org.openqa.selenium.WebElement toWebElement()
public org.openqa.selenium.WebElement getWrappedElement()
getWrappedElement
in interface org.openqa.selenium.internal.WrapsElement
public void click(int offsetX, int offsetY)
Driver Type: Desktop
offsetX
- is offset from LeftoffsetY
- is offset from Toppublic void click()
By default it uses default Selenium method click.
click
in interface org.openqa.selenium.WebElement
public UiElement contextClick(int offsetX, int offsetY)
Driver Type: Desktop
offsetX
- is offset from LeftoffsetY
- is offset from Toppublic UiElement contextClick()
public UiElement singleClick(int offsetX, int offsetY)
click(int, int)
, but returns UiElement. Helpful for chaining
$("[CLASS:Edit; INSTANCE:1]").singleClick(10, 10).sendKeys(text);
Driver Type: Desktop
offsetX
- is offset from LeftoffsetY
- is offset from Toppublic UiElement singleClick()
click()
, but returns UiElement. Helpful for chaining
$("[CLASS:Edit; INSTANCE:1]").singleClick().sendKeys(text);
public UiElement doubleClick(int offsetX, int offsetY)
Driver Type: Desktop
offsetX
- is offset from LeftoffsetY
- is offset from Toppublic UiElement doubleClick()
public UiElement tripleClick(int offsetX, int offsetY)
Driver Type: Desktop
offsetX
- is offset from LeftoffsetY
- is offset from Toppublic UiElement tripleClick()
Driver Type: Desktop
public UiElement click(int clicks, int offsetX, int offsetY)
Driver Type: Desktop
clicks
- number of clicksoffsetX
- is offset from LeftoffsetY
- is offset from Toppublic UiElement click(int clicks)
Driver Type: Desktop
clicks
- number of clickspublic UiElement wheelClick(int offsetX, int offsetY)
Driver Type: Desktop
offsetX
- is offset from LeftoffsetY
- is offset from Toppublic UiElement wheelClick()
Driver Type: Desktop
public UiElement hover()
public boolean isImageLoaded()
Driver Type: Web
IllegalArgumentException
- if argument is not an "img" elementpublic void submit()
submit
in interface org.openqa.selenium.WebElement
public void sendKeys(CharSequence... charSequences)
sendKeys
in interface org.openqa.selenium.WebElement
public void clear()
clear
in interface org.openqa.selenium.WebElement
public String getTagName()
getTagName
in interface org.openqa.selenium.WebElement
public String getAttribute(String s)
getAttribute
in interface org.openqa.selenium.WebElement
public boolean isSelected()
isSelected
in interface org.openqa.selenium.WebElement
public boolean isEnabled()
isEnabled
in interface org.openqa.selenium.WebElement
public boolean focus()
focus
in interface org.openqa.selenium.WebElement
public boolean isDisplayed()
isDisplayed
in interface org.openqa.selenium.WebElement
public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
findElements
in interface org.openqa.selenium.SearchContext
findElements
in interface org.openqa.selenium.WebElement
public org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
findElement
in interface org.openqa.selenium.SearchContext
findElement
in interface org.openqa.selenium.WebElement
public org.openqa.selenium.Point getLocation()
getLocation
in interface org.openqa.selenium.WebElement
public org.openqa.selenium.Dimension getSize()
getSize
in interface org.openqa.selenium.WebElement
public org.openqa.selenium.Rectangle getRect()
getRect
in interface org.openqa.selenium.WebElement
public String getCssValue(String s)
getCssValue
in interface org.openqa.selenium.WebElement
public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> outputType)
getScreenshotAs
in interface org.openqa.selenium.TakesScreenshot
public String getId()
getId
in interface org.openqa.selenium.internal.HasIdentity
public org.openqa.selenium.interactions.internal.Coordinates getCoordinates()
getCoordinates
in interface org.openqa.selenium.internal.Locatable
public String copySelectedText()
Driver Type: Desktop
public String selectAllTextAndCopy()
Driver Type: Desktop
public int top()
public int left()
public int bottom()
public int right()
public int centerX()
public int centerY()
Copyright 2016, WorkFusion, Inc.