selenium-ide icon indicating copy to clipboard operation
selenium-ide copied to clipboard

Upload a file

Open ghost opened this issue 8 years ago • 33 comments

Add ability to upload a file

Previously, uploading a file was: Command: type Target (xpath/css): data.upload.whatever Value (file path): /users/foo/bar/file.png

Now it doesn't work and gives an error: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.

ghost avatar Mar 07 '18 05:03 ghost

I'm afraid that's currently impossible,
The new extension standard doesn't allow filesystem access, to protect users.

corevo avatar Mar 07 '18 08:03 corevo

Cant you simulate it somehow? Serialize the file as part of the project?

On Mar 7, 2018 10:03, "Tomer Steinfeld" [email protected] wrote:

Closed #120 https://github.com/SeleniumHQ/selenium-ide/issues/120.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SeleniumHQ/selenium-ide/issues/120#event-1508277566, or mute the thread https://github.com/notifications/unsubscribe-auth/AD_LoJXJyLw3r_GGBcwqv7Wf8BwFSC7aks5tb5RKgaJpZM4Sf4Ie .

carmiadam avatar Mar 07 '18 08:03 carmiadam

I can add a file upload, and save it as base64 as part of the project,
I'll also need to add some kind of file management view to delete old files.

corevo avatar Mar 07 '18 08:03 corevo

Not being able to upload a file would be a disaster. Countless tests involve uploading an image or a video such as a profile image or album or youtube video.

ghost avatar Mar 07 '18 19:03 ghost

The Kantu Selenium IDE can upload files, see https://a9t9.com/kantu/docs/webextensions#fileupload - so technically it is doable.

idefix1 avatar Mar 09 '18 10:03 idefix1

@idefix, He said he can, but didn’t want.

Jongkeun avatar Mar 09 '18 10:03 Jongkeun

@Jongkeun Ah, yes, I missed that. But also, Kantu uses a direct file upload, not the base64 method suggested here. So no need to add file management.

idefix1 avatar Mar 09 '18 10:03 idefix1

We threw a few ideas at the office, I’ve found a workaround for chrome, but it doesn’t work on Firefox.

Cheers, Tom

On 9 Mar 2018, 12:05 +0200, idefix1 [email protected], wrote:

@Jongkeun Ah, yes, I missed that. — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

corevo avatar Mar 09 '18 17:03 corevo

Just here to update, I'm working on it for Chrome,
Firefox might take a bit longer because the same method doesn't work for it.
I'm gonna look for a way to bring file upload to both.
Anyway like Kantu, using this workaround I won't be able to recreate the path the file was uploaded from, and you'll have to reenter it.

corevo avatar Mar 11 '18 08:03 corevo

We have a way to get this working on Chrome,
In playback it's gonna work on Chrome, and once we change the playback to work on top of webdriver instead of selenium core, we'll ship it to Firefox as well.
Just to note, we're gonna finish up working on running in CI on top of webdriver as well, which we will support file upload in too, so that you can use it with firefox that way.

corevo avatar Mar 12 '18 08:03 corevo

Thank you. I'm waiting for this to be shipped to the selenium ide chrome extension!

jasetom avatar Mar 12 '18 15:03 jasetom

I'm running the current release in Chrome from April (after Mar 13) and there does not appear to be a way to upload a file. I'm looking for commands like "get file" or "upload file" and don't see any.

ghost avatar Apr 26 '18 00:04 ghost

Just like in Selenium, use:
type | locator to input[type="file"] | /path/to/the/file.png

corevo avatar Apr 26 '18 13:04 corevo

This still does not work on the latest Chrome. Has anyone actually tried this?

kwmtang avatar Aug 01 '18 07:08 kwmtang

This test is ran daily, and confirmed working.
@kwmtang Yes people test this and try this. aug-01-2018 11-06-22

corevo avatar Aug 01 '18 08:08 corevo

OK. I just tried it on the Github profile picture and I found:

Using this target works: id=upload-profile-picture

But using this target doesn't work: //*[@id="upload-profile-picture"]

They mean the exact same thing except the first one is css and the 2nd is xpath. This looks like a bug.

kwmtang avatar Aug 01 '18 08:08 kwmtang

xpath isn't supported, because the underlying engine used doesn't support it.
Furthermore the reference tab and errors say this exact thing.

corevo avatar Aug 01 '18 08:08 corevo

No way!! Selenium not supporting xpath is like a Chinese restaurant not serving rice!!!

kwmtang avatar Aug 01 '18 08:08 kwmtang

But this isn't a selenium command (hehe), webextensions don't support selenium file uploads, instead we are using Chrome debugging protocol, that only supports query selectors.

corevo avatar Aug 01 '18 08:08 corevo

This is gotta be a P0 blocker. How can Selenium IDE be expected to survive without this feature? My devs almost never have the time to make ids with all the crazy fields and buttons that need to be made every sprint and QA makes do with whatever crazy fragile xpaths we can use. We are able to keep up because IDE is so much faster to write than our TestNG and RobotFramework tests. Can we escalate this somehow? This is a mission critical feature. Any testing of a modern site/app will normally include uploading images, documents, audio, and video files.

kwmtang avatar Aug 01 '18 08:08 kwmtang