public interface WebElementActionBuilder
During an action, the ibello tries to interact with an element on the page.
If the interaction fails, it will try it again and again, until it successes or the time
runs out. By default, an action uses the ibello
default timeout, but it can be changed with the TimeoutRelated.withTimeout(Enum) or
TimeoutRelated.withTimeout(String) method.
In some cases it is useful to wait a few seconds after an interaction occurred on the page.
The action may change the page structure dynamically, or can navigate to another page.
With the withPageRefreshWait() method, this wait can be performed right after
the action finishes.
During test execution, every action is logged with it's additional information. If an action
fails, then the test will be marked with "error" flag, and not with "failed". This is a
difference between actions and expectations - see hu.ibello.expect.
WebElementActionBuilder instance can be obtained on page objects, with PageObject.doWith(WebElement)
method.
Examples:
WebElement button = ...; WebElement inputField = ...; doWith(button).withPageRefreshWait().click(); doWith(inputField).sendKeys(keys().CONTROL(), "a");
| Modifier and Type | Method and Description |
|---|---|
void |
click()
Click the current element.
|
void |
contextClick()
Right (context-) click on the current element.
|
void |
doubleClick()
Double click on the current element.
|
void |
dragAndDropTo(WebElement target)
Drags the current element and drops to the given target.
|
default void |
fireEvent(Events event)
Fires an event on the element.
|
void |
fireEvent(String eventName)
Fires an event on the element.
|
void |
moveTo()
Move the cursor to the center of the current element.
|
void |
scrollTo(WebElement target)
Scrolls the current element (if it is scrollable) to the given target element.
|
void |
selectOption(int index)
Select an option from the dropdown list, with the given index.
|
void |
selectOption(String text)
Select an option from the dropdown list, with the given text.
|
void |
sendKeys(CharSequence... keys)
Send the given character sequences (strings) to the current element.
|
void |
sendKeys(KeyModifier modifier,
CharSequence... keys)
Send the given character sequences (strings) to the current element, with the given
KeyModifier. |
default void |
setFile(File file)
Set the value of the current element, which should be a file input.
|
void |
setFile(String filePath)
Set the value of the current element, which should be a file input.
|
void |
setSelected(boolean selected)
This method works for checkboxes and radio buttons.
|
void |
setValue(String value)
Set the value of the current element, which should be a text input field or a textarea.
|
void |
submit()
Submit the current element, which should be a
form. |
B |
withPageRefreshWait()
If this method is called on the action builder instance, and then an action
is executed successfully, the program will wait until the page is refreshed and
all dynamic changes in the DOM performed.
|
withTimeout, withTimeoutvoid click()
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
void dragAndDropTo(WebElement target)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
target - drop targetvoid contextClick()
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
void doubleClick()
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
void selectOption(String text)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
text - the text of the option we want to selectvoid selectOption(int index)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
index - the index of the option we want to selectvoid moveTo()
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
void scrollTo(WebElement target)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
target - the target element to which we want to scrollvoid sendKeys(CharSequence... keys)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
keys - character sequences to sendvoid sendKeys(KeyModifier modifier, CharSequence... keys)
KeyModifier.
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
modifier - key modifier which should be activatedkeys - character sequences to sendKeyModifiervoid submit()
form.
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
void setValue(String value)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
value - the new valuevoid setFile(String filePath)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
filePath - path of the file to setdefault void setFile(File file)
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
file - the file to setvoid fireEvent(String eventName)
Events instance.eventName - the name of the eventdefault void fireEvent(Events event)
Events instance.event - the type of the eventvoid setSelected(boolean selected)
For radio buttons, the only acceptable parameter of this method is true.
There is no quick solution to unselect a radio button.
During the timeout, this method tries to execute the action until it is successfully performed. If the time runs out and the action was not performed, an exception will be thrown, the error will be logged and the current test will be interrupted and marked as "error".
selected - should be the checkbox selectedB withPageRefreshWait()
Created by Kornél Simon, 2022