Skip to content
Merged
Changes from 1 commit
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: 14 additions & 0 deletions appium/webdriver/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from selenium.webdriver.common.by import By
from selenium.webdriver.common.utils import keys_to_typing
from selenium.webdriver.remote.command import Command as RemoteCommand

from .extensions.search_context import AppiumWebElementSearchContext
Expand Down Expand Up @@ -204,3 +205,16 @@ def set_value(self, value):
}
self._execute(Command.SET_IMMEDIATE_VALUE, data)
return self

def send_keys_direct(self, *value):
Copy link
Contributor

@mykola-mokhnach mykola-mokhnach Apr 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather override the original selenium's implementation of send_keys. We don't support sending files in neither of Appium drivers.

Copy link
Member Author

@KazuCocoa KazuCocoa Apr 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, for mobile browser, too? I considered browser cases. (I know we don't support it for native apps)

I found Ruby binding handled the behaviour with a flag, so I wondered if we also do a similar thing for send_keys if mobile safari/chrome can work as same as desktop browser.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safari mobile driver for sure does not support local files upload. Let me check chromedriver sources

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromedriver handles the path inside sendKeys handler: https://github.com/bayandin/chromedriver/blob/47f9916496782bf8c1a031a3c1f1f0c7cf654da1/element_commands.cc#L452

This means there is also no need to modify/patch the call on the client side

Copy link
Contributor

@mykola-mokhnach mykola-mokhnach Apr 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've never declared file upload support anyway: appium/appium#13156

However, in case of mobile Chromedriver (at least according to what is present in its code) it might be possible to provide a remote file path into sendKeys endpoint and in case the target input is of type file and the remote path exists (the file must be uploaded to the device and located somewhere, where it would accessible for the browser's or webview owner's process) the feature should work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍
Thanks for the investigation

"""Simulates typing into the element.

Please consider to use this method if WebElement#send_keys did not work.
WebElement#send_keys works uploading a local file, but this method simply
sends given string without such uploading.

Argument is the same as WebElement#send_keys
"""
self._execute(RemoteCommand.SEND_KEYS_TO_ELEMENT,
{'text': "".join(keys_to_typing(value)),
'value': keys_to_typing(value)})