fix: set_value and set_text sent incorrect data#831
Conversation
|
|
What is the actual error you get from the server? |
Thanks for the quick reply, highly appreciated! |
|
CLA should be fixed now. |
|
I think you could just add |
5db66bd to
57fb835
Compare
|
That sadly does not seem to be possible EDIT: I tried it with the following patch From 5db66bd9e9bd747ff2a4802eec1552bc2154a64e Mon Sep 17 00:00:00 2001
From: eyJhb <eyjhbb@gmail.com>
Date: Fri, 17 Feb 2023 08:30:27 +0100
Subject: [PATCH] fix: set_value and set_text sent incorrect data
---
appium/webdriver/webdriver.py | 1 +
appium/webdriver/webelement.py | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py
index 2866b9e9..430ab17b 100644
--- a/appium/webdriver/webdriver.py
+++ b/appium/webdriver/webdriver.py
@@ -445,6 +445,7 @@ def set_value(self: T, element: MobileWebElement, value: str) -> T:
data = {
'id': element.id,
'value': [value],
+ 'text': value,
}
self.execute(Command.SET_IMMEDIATE_VALUE, data)
return self
diff --git a/appium/webdriver/webelement.py b/appium/webdriver/webelement.py
index 128ceb0c..a8133d5a 100644
--- a/appium/webdriver/webelement.py
+++ b/appium/webdriver/webelement.py
@@ -170,7 +170,7 @@ def set_text(self, keys: str = '') -> 'WebElement':
Returns:
`appium.webdriver.webelement.WebElement`
"""
- data = {'id': self._id, 'value': [keys]}
+ data = {'id': self._id, 'value': [keys], 'text': keys}
self._execute(Command.REPLACE_KEYS, data)
return self
@@ -198,8 +198,9 @@ def set_value(self, value: str) -> 'WebElement':
`appium.webdriver.webelement.WebElement`
"""
data = {
'id': self.id,
'value': [value],
+ 'text': value,
}
self._execute(Command.SET_IMMEDIATE_VALUE, data)
return self |
|
@eyJhb could also also provide the full server log for your patch. This seems weird to me as the validation algorithm looks fine to me: |
|
Keep in mind, there are the two methods
EDIT: I hope this was what was meant by the logs for the request. Is there anything more that I should send? |
|
ah, now I see which endpoint is used. Both endpoints were deprecated and they are not recommended for use anymore: I think the current change is ok, however both APIs should be marked as deprecated. |
|
Which endpoint should be used instead? Also, what is the best way to indicate the deprecation? I am unsure of the best formatting, based on the other deprecation I can see. warnings.warn(
'The "launchApp" API is deprecated and will be removed in future versions. '
'See https://github.com/appium/python-client/pull/831',
DeprecationWarning,
)Or what link would make sense? |
|
yes the warning above makes sense. Also the deprecation must be mentioned in the docstring. regarding what to use instead - just a regular send_keys. Internally xcuitest driver still redirects to the same POST /value call: |
|
Should be fixed not, unsure about the deprecated version, so I've just put the current one :) |
|
I am unsure how the unit tests should be fixed :) |
I think it would probably make sense to remove this test for good as we don't really need to verify deprecated entries |
should be assert d['text'] == value
|
Should be fixed now :) Thanks! |
set_textandset_valuewould not work, without these changes, on the latest beta56 of Appium.These are the values that Appium corrected me with, that I have replaced in the code.
Is there any place where one would validate the parameters that should be sent? Either some documentation, or a reference library?
EDIT: is this the reference to use? https://w3c.github.io/webdriver/#element-send-keys