Sitelet https://github.com/appium/python-client/pull/831/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions appium/webdriver/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# pylint: disable=too-many-lines,too-many-public-methods,too-many-statements,no-self-use

import warnings
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union

from selenium import webdriver
Expand Down Expand Up @@ -434,6 +435,7 @@ def create_web_element(self, element_id: Union[int, str]) -> MobileWebElement:

def set_value(self: T, element: MobileWebElement, value: str) -> T:
"""Set the value on an element in the application.
deprecated:: 2.8.1

Args:
element: the element whose value will be set
Expand All @@ -442,10 +444,14 @@ def set_value(self: T, element: MobileWebElement, value: str) -> T:
Returns:
`appium.webdriver.webdriver.WebDriver`: Self instance
"""
data = {
'id': element.id,
'value': [value],
}
warnings.warn(
'The "setValue" API is deprecated and will be removed in future versions. '
Comment thread
mykola-mokhnach marked this conversation as resolved.
'Instead the "send_keys" API or W3C Actions can be used. '
'See https://github.com/appium/python-client/pull/831',
DeprecationWarning,
)

data = {'text': value}
self.execute(Command.SET_IMMEDIATE_VALUE, data)
return self

Expand Down
24 changes: 19 additions & 5 deletions appium/webdriver/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
from typing import Callable, Dict, List, Optional, Union

from selenium.webdriver.common.utils import keys_to_typing
Expand Down Expand Up @@ -157,6 +158,7 @@ def clear(self) -> 'WebElement':

def set_text(self, keys: str = '') -> 'WebElement':
"""Sends text to the element.
deprecated:: 2.8.1

Previous text is removed.
Android only.
Expand All @@ -170,7 +172,14 @@ def set_text(self, keys: str = '') -> 'WebElement':
Returns:
`appium.webdriver.webelement.WebElement`
"""
data = {'id': self._id, 'value': [keys]}
warnings.warn(
'The "setText" API is deprecated and will be removed in future versions. '
'Instead the "send_keys" API or W3C Actions can be used. '
'See https://github.com/appium/python-client/pull/831',
DeprecationWarning,
)

data = {'text': keys}
self._execute(Command.REPLACE_KEYS, data)
return self

Expand All @@ -190,17 +199,22 @@ def location_in_view(self) -> Dict[str, int]:

def set_value(self, value: str) -> 'WebElement':
"""Set the value on this element in the application
deprecated:: 2.8.1

Args:
value: The value to be set

Returns:
`appium.webdriver.webelement.WebElement`
"""
data = {
'id': self.id,
'value': [value],
}
warnings.warn(
'The "setValue" API is deprecated and will be removed in future versions. '
'Instead the "send_keys" API or W3C Actions can be used. '
'See https://github.com/appium/python-client/pull/831',
DeprecationWarning,
)

data = {'text': value}
self._execute(Command.SET_IMMEDIATE_VALUE, data)
return self

Expand Down
2 changes: 1 addition & 1 deletion test/unit/webdriver/webelement_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_set_value(self):
element.set_value(value)

d = get_httpretty_request_body(httpretty.last_request())
assert d['value'] == [value]
assert d['text'] == value

@httpretty.activate
def test_send_key(self):
Expand Down