Package com.codeborne.selenide.commands
Class Clear
java.lang.Object
com.codeborne.selenide.FluentCommand
com.codeborne.selenide.commands.Clear
- All Implemented Interfaces:
Command<SelenideElement>
- Direct Known Subclasses:
AppiumClear
,ClearWithShortcut
Clean the input field value.
The standard Selenium method WebElement.clear()
does not help in case of
"tricky" inputs generated by Vue.js, React and other fancy frameworks.
That's why we need to clear the field value by emulating real user actions:
- Select the whole text
- press "Backspace"
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
blurSafely
(Driver driver, org.openqa.selenium.WebElement input) protected void
Clear the input content without triggering "change" and "blur" eventsprotected void
clearAndTrigger
(Driver driver, org.openqa.selenium.WebElement input) Clear the input content and trigger "change" and "blur" eventsprotected void
execute
(WebElementSource locator, Object @Nullable [] args) Methods inherited from class com.codeborne.selenide.FluentCommand
execute
-
Constructor Details
-
Clear
public Clear()
-
-
Method Details
-
execute
- Specified by:
execute
in classFluentCommand
-
clearAndTrigger
Clear the input content and trigger "change" and "blur" eventsThis is the shortest keys combination I found in May 2022.
It seems to work in Firefox, Chrome on Mac and on Linux smoothly. -
blurSafely
-
clear
Clear the input content without triggering "change" and "blur" events
-