public class HtmlElement extends Object implements org.openqa.selenium.WebElement, org.openqa.selenium.WrapsElement, Named
Name annotation if necessary
and fill it with elements.
For example:
@Name("Search Form")
@FindBy(css = "form_css")
public class SearchForm extends HtmlElement {
@Name("Request Input")
@FindBy(css = "request_input_css")
private TextInput requestInput;
@Name("Search Button")
@FindBy(css = "search_button_css")
private Button searchButton;
public TextInput getRequestInput() {
return requestInput;
}
public Button getSearchButton() {
return searchButton;
}
}
Then you can use created blocks as fields of page objects or you can also initialize them directly with methods of
HtmlElementLoader class.
Note that this class implements WebElement interface so you can substitute instances of your block classes
for WebElements where it's necessary.| Constructor and Description |
|---|
HtmlElement() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
If this element is a text entry element, this will clear the value.
|
void |
click()
Clicks this element.
|
boolean |
exists()
Determines whether or not this element exists on page.
|
org.openqa.selenium.WebElement |
findElement(org.openqa.selenium.By by)
Find the first
WebElement using the given mechanism. |
List<org.openqa.selenium.WebElement> |
findElements(org.openqa.selenium.By by)
Finds all elements within the current context using the given mechanism.
|
String |
getAttribute(String name)
Gets the value of a the given attribute of the element.
|
String |
getCssValue(String name)
Gets the value of a given CSS property.
|
org.openqa.selenium.Point |
getLocation()
Gets position of the top left-hand corner of the rendered element on page.
|
String |
getName()
Returns name of the entity.
|
org.openqa.selenium.Rectangle |
getRect() |
<X> X |
getScreenshotAs(org.openqa.selenium.OutputType<X> outputType) |
org.openqa.selenium.Dimension |
getSize()
Gets width and height of the rendered element.
|
String |
getTagName()
Gets the tag name of this element.
|
String |
getText()
Gets the visible inner text of this element.
|
org.openqa.selenium.WebElement |
getWrappedElement() |
boolean |
isDisplayed()
Indicates if this element is displayed or not.
|
boolean |
isEnabled()
Indicates if the element is currently enabled or not.
|
boolean |
isSelected()
Indicates whether this element is selected or not.
|
void |
sendKeys(CharSequence... charSequences)
Simulates typing into an element.
|
void |
setName(String name)
Sets a name of a block.
|
void |
setWrappedElement(org.openqa.selenium.WebElement wrappedElement)
Sets the wrapped
WebElement. |
void |
submit()
If this element is a form, or an element within a form, then this will submit this form to
the remote server.
|
String |
toString()
Returns specified name, actually the same as
getName() method. |
public org.openqa.selenium.WebElement getWrappedElement()
getWrappedElement in interface org.openqa.selenium.WrapsElementpublic void setWrappedElement(org.openqa.selenium.WebElement wrappedElement)
WebElement. This method is used by initialization mechanism and is not intended
to be used directly.wrappedElement - WebElement to wrap.public String getName()
Namedpublic void setName(String name)
name - Name to set.public boolean exists()
public void click()
WebElement.click() for more details.click in interface org.openqa.selenium.WebElementpublic void submit()
WebElement.submit() for more details.submit in interface org.openqa.selenium.WebElementpublic void sendKeys(CharSequence... charSequences)
WebElement.sendKeys(CharSequence...) for more details.sendKeys in interface org.openqa.selenium.WebElementcharSequences - Symbols to be typed into an element.public void clear()
WebElement.clear() for more details.clear in interface org.openqa.selenium.WebElementpublic String getTagName()
WebElement.getTagName() for more details.getTagName in interface org.openqa.selenium.WebElementpublic String getAttribute(String name)
WebElement.getAttribute(String)
for more details.getAttribute in interface org.openqa.selenium.WebElementname - The name of the attribute.public boolean isSelected()
WebElement.isSelected()
for more details.isSelected in interface org.openqa.selenium.WebElementpublic boolean isEnabled()
WebElement.isEnabled()
for more details.isEnabled in interface org.openqa.selenium.WebElementpublic String getText()
WebElement.getText()
for more details.getText in interface org.openqa.selenium.WebElementpublic List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
WebElement.findElements(org.openqa.selenium.By) for more details.findElements in interface org.openqa.selenium.SearchContextfindElements in interface org.openqa.selenium.WebElementby - The locating mechanism to use.WebElements, or an empty list if nothing matches.public org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
WebElement using the given mechanism. See
WebElement.findElement(org.openqa.selenium.By) for more details.findElement in interface org.openqa.selenium.SearchContextfindElement in interface org.openqa.selenium.WebElementby - The locating mechanism.org.openqa.selenium.NoSuchElementException - If no matching elements are found.public boolean isDisplayed()
WebElement.isDisplayed()
for more details.isDisplayed in interface org.openqa.selenium.WebElementpublic org.openqa.selenium.Point getLocation()
WebElement.getLocation() for more details.getLocation in interface org.openqa.selenium.WebElementpublic org.openqa.selenium.Dimension getSize()
WebElement.getSize()
for more details.getSize in interface org.openqa.selenium.WebElementpublic org.openqa.selenium.Rectangle getRect()
getRect in interface org.openqa.selenium.WebElementpublic String getCssValue(String name)
WebElement.getCssValue(String) for more details.getCssValue in interface org.openqa.selenium.WebElementname - Name of the property.public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> outputType)
throws org.openqa.selenium.WebDriverException
getScreenshotAs in interface org.openqa.selenium.TakesScreenshotorg.openqa.selenium.WebDriverExceptionCopyright © 2023 Yandex. All rights reserved.