Skip to content

Commit 54a082e

Browse files
authored
Revert "chore: remove duplicated clean command" (appium#881)
* Revert "chore: remove duplicated clean command (appium#809)" This reverts commit 2f45ef9. * chore: left a comment * trim spaces
1 parent a8db6a2 commit 54a082e

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

appium/webdriver/mobilecommand.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class MobileCommand:
3131
DEACTIVATE_IME_ENGINE = 'deactivateIMEEngine'
3232
GET_ACTIVE_IME_ENGINE = 'getActiveEngine'
3333

34+
CLEAR = 'clear'
3435
LOCATION_IN_VIEW = 'locationInView'
3536

3637
CONTEXTS = 'getContexts'

appium/webdriver/webdriver.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ def _add_commands(self) -> None:
575575
'POST',
576576
'/session/$sessionId/appium/element/$id/replace_value',
577577
)
578+
commands[Command.CLEAR] = ('POST', '/session/$sessionId/element/$id/clear')
578579
commands[Command.LOCATION_IN_VIEW] = (
579580
'GET',
580581
'/session/$sessionId/element/$id/location_in_view',

appium/webdriver/webelement.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ def find_elements(self, by: str = AppiumBy.ID, value: Union[str, Dict, None] = N
144144

145145
return self._execute(RemoteCommand.FIND_CHILD_ELEMENTS, {"using": by, "value": value})['value']
146146

147+
def clear(self) -> 'WebElement':
148+
"""Clears text.
149+
150+
Override for Appium
151+
152+
Returns:
153+
`appium.webdriver.webelement.WebElement`
154+
"""
155+
156+
# NOTE: this method is overridden because the selenium client returned None instead of self.
157+
# Appium python cleint would like to allow users to chain methods.
158+
data = {'id': self.id}
159+
self._execute(Command.CLEAR, data)
160+
return self
161+
147162
def set_text(self, keys: str = '') -> 'WebElement':
148163
"""Sends text to the element.
149164
deprecated:: 2.8.1

0 commit comments

Comments
 (0)