Commit 83f689a4 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Fix file upload on Android

While sending file name to <input type='file'>, ChromeDriver can only
check for the file existence on the local file system. This isn't
correct for Android and remote browsers. This is now fixed.

Bug: chromedriver:2339
Change-Id: Ie900513f028fee36485d477fada5a59c4e33dd22
Reviewed-on: https://chromium-review.googlesource.com/1087668Reviewed-by: default avatarJonathon Kereliuk <kereliuk@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564871}
parent 324138ca
......@@ -327,12 +327,17 @@ Status ExecuteSendKeysToElement(Session* session,
paths_string.append(path_part);
}
ChromeDesktopImpl* chrome_desktop = nullptr;
bool is_desktop = session->chrome->GetAsDesktop(&chrome_desktop).IsOk();
// Separate the string into separate paths, delimited by '\n'.
std::vector<base::FilePath> paths;
for (const auto& path_piece : base::SplitStringPiece(
paths_string, base::FilePath::StringType(1, '\n'),
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
if (!base::PathExists(base::FilePath(path_piece))) {
// For local desktop browser, verify that the file exists.
// No easy way to do that for remote or mobile browser.
if (is_desktop && !base::PathExists(base::FilePath(path_piece))) {
return Status(
kInvalidArgument,
base::StringPrintf("File not found : %" PRIsFP,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment