Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Selenium allows to sendKeys into an invisible input type=file #7625

Open
lukeis opened this issue Mar 4, 2016 · 32 comments
Open

Selenium allows to sendKeys into an invisible input type=file #7625

lukeis opened this issue Mar 4, 2016 · 32 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 4, 2016

Originally reported on Google Code with ID 7625


What steps will reproduce the problem?
Tried to upload a document in simple browser button.
Sample Code:
<file id=file>
 <input id=browse name=browse type=file/>
</file>

Actual Result:
1. This element is not hidden but when worked with Internet Explorer version: 2.41,
it is not taking the element.
2. When checked with .size(), it is giving me =1.
3. When checked with .isDisplayed(), it is giving out= false.
4. Working in all other browsers fine..
5. Working fine with Internet Explorer version: 2.36.

What is the expected output? What do you see instead?
1. This should support the upgraded IE Driver version as well.


Selenium version:2.39
OS:Windows 7
Browser: IE 9 (IEDriver 2.41)
Browser version: 2.41


Reported by goyal.vipul68 on 2014-07-19 13:14:20

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Please provide a complete executable scenario and a complete sample page to reproduce
the issue 

Reported by barancev on 2014-07-21 19:32:39

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I cant share with the page on which i am working due to privacy and is not available
open.
But I can provide you the code:
Browse... <iframe id="uploadPackage" scrolling="no" frameborder="0" border="0" style="width: 0px; height: 0px;" name="uploadPackage">

In this iframe is used to show any error message.. not to upload any doc.
When this INPUT Element is accessed using IE Driver 2.41, it is not accessing this
element.

While debugging i checked:
size() == 1;
isEnabled == true;
isDisplayed == false;

It is giving false for isDisplayed, which is true in the case of other browsers.

When i downgraded the IEdriver version to 2.36, it started recognizing this INPUT element.

Reported by goyal.vipul68 on 2014-07-22 17:35:37

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I'm having the same issue with selenium version 2.42 when using InputElement.SendKeys(path)method
to upload a file.
When I use version 2.39 it works perfectly.

With version 2.42, the script works for one input controller but gives an exception
for another controller. I'm using the same method to send the path in both places.
The difference I noticed was, the failing controller allows multiple files. I'm posting
the code below for reference. 

---------------------------------------------------
This accepts only one file - works well with 2.42
Displayed = true

<input type="file" tabindex="6" id="packingListUpload" name="uploadedFile" class="valid">

---------------------------------------------------
This accepts multiple files - gives an exception with 2.42
Displayed = false with 2.42.
with 2.39 it's Displayed = true

<input type="file" name="excludeDocument" id="excludeDocument" data-role="upload" multiple="multiple"
autocomplete="off">

---------------------------------------------------

Reported by mail4kodi on 2014-08-07 06:11:04

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I experience the same issue, had to freeze to version 2.39 because after that it complains
that input is hidden on my target browsers: IE11, IE10, IE9. However Chrome and Firefox
works perfectly on newer versions like 2.40 2.41 2.42

Reported by leonardogallucci on 2014-08-13 16:29:49

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I think after these encounters the issue is self explanatory.
Please have a look over it and fix the same.

Reported by goyal.vipul68 on 2014-08-13 16:32:47

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Closing the issue as there is no reproduction case provided.

Reported by barancev on 2014-09-15 02:54:35

  • Status changed: Invalid

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

You can use the following site to reproduce the problem. I tried with IE Driver Server
2.43.

http://demos.telerik.com/kendo-ui/upload/index

Reported by mail4kodi on 2014-09-15 13:07:06

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Open the issue again as this is properly reproducable issue and is encountered by many
of the users..
Above is the webpage which can be used to replicate the issue

Reported by goyal.vipul68 on 2014-09-15 13:38:52

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

The file input on the mentioned page is obviousely invisible, it has opacity=0

Drivers for IE, Firefox, Chrome all return false as the result of isDisplayed for this
element, as expected.

Reported by barancev on 2014-09-15 15:26:40

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

But if you use IE Driver Server 2.39 it will upload a file to this controller using
the same method. 
Please refer the attached video

Reported by mail4kodi on 2014-09-15 15:54:31


- _Attachment: [selenium issue.mp4](https://storage.googleapis.com/google-code-attachments/selenium/issue-7625/comment-10/selenium issue.mp4)_

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

So it was a bug in IE driver 2.39

Reported by barancev on 2014-09-15 16:07:42

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

So you are saying that my code was working with buggy IE driver and now I can't use
it?

Reported by mail4kodi on 2014-09-15 16:11:22

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I want to say Selenium can't (won't) deal with invisible elements.

But you can use executeJavascript to make an input field visible and fill it.

Reported by barancev on 2014-09-15 16:16:32

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I can reproduce.

I don't need to executeJavascript to make the input field visible on Chrome or Firefox
but now I need to for IEDriver > 2.39.

Note modern upload pages doesn't show (make visible) the input type=file file name
next to the upload button because they tend to show it nicely in some other place like
the testing example provided by mail4k...@gmail.com.

So Selenium does deal with the invisible upload input on Chrome & Firefox. Is that
a bug? I hope not because uploading for invisible input type=file is so common and
will break my tests if you fix that instead of fixing IEDriver > 2.39 which I think
is the cool solution here ;)

Reported by leonardogallucci on 2014-09-15 17:42:33

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Ah, I see, the issue is not about isDisplayed, it works well.

The real "problem" is ability to sendKeys to an invisible file input field in FF and
Chrome. The specification [1] says:

"
[section 14.3.3] A requirement for key-based interaction with an element is that it
is interactable.
...
[section 14.1] The following conditions must be met for the element to be considered
interactable:
- The element must be displayed, as defined in section 10.1.
...
"

IE conforms to the specification, whereas FF and Chrome don't.

Iа you disagree with this design decision you may raise an issue against the specification
in [2].

[1] https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html
[2] http://goo.gl/LxCtcV

Reported by barancev on 2014-09-18 15:10:48

  • Status changed: Accepted
  • Labels added: Browser-Firefox, Browser-Chrome
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Done: https://www.w3.org/Bugs/Public/show_bug.cgi?id=26849

Reported by leonardogallucci on 2014-09-18 17:13:38

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Issue 8138 has been merged into this issue.

Reported by barancev on 2014-11-06 09:07:23

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Issue 8138 has been merged into this issue.

Reported by barancev on 2014-11-06 12:02:28

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

If ability to sendkeys to an invisible file input field in FF & Chrome is stopped.Its
going to break almost all test related to file uploading in our suite.As of now it
does not work with IE9 :(


Reported by rahul.lakade on 2014-12-05 09:50:12

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I think this issue should be merged with this other one, they are the same thing:

https://code.google.com/p/selenium/issues/detail?id=3858

Reported by cbaldan@daitangroup.com on 2015-03-11 03:29:39

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Closing the issue as the current implementation conforms to the current specification.
as soon as the issue raised on the specification will be fixed we'll update the implementation.

Reported by barancev on 2015-04-03 19:25:34

  • Status changed: WontFix

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

barancev, if you want the whole thing to be compliant with the specification, I suggest
to remove this feature from Firefox and Chrome driver as they currently support something
they should not.

Reported by cleber.baldan on 2015-04-03 22:11:48

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Oh, sorry, I meant to say that *IE* conforms to the current specification. Firefox and
Chrome conform to the future state of the spec, let them be ahead of the time. There
is no need to break existing client code twice in short time period :)

But IE is more conservative and wants the spec to be updated first. OK, let's reopen
this issue on IE again and wait for the spec to be changed :)

Reported by barancev on 2015-04-05 10:49:31

  • Status changed: Accepted
  • Labels added: Browser-IE
  • Labels removed: Browser-Firefox, Browser-Chrome

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by barancev on 2015-04-05 10:49:52

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Way to go barancev!

Nowadays the only way I could find to overcome this lack of support of support in IE
and Safari driver is using a web server that has a public IP and then make the test
get the resource (image, file, whatever) from that server.
The problem is that not every client/company has the needed hardware/IP/security policies
mild enough so we can get an Apache up to the testing team.

cheers!

Reported by cleber.baldan on 2015-04-05 13:44:02

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

This is a very common issue and I believe a lot of users have encountered. In my case,
all the tests related to file uploading are blocked now on IE. I've no idea whether
there are workarounds for this issue. It's not working properly for me even i use execute
Javascript to set the element visible. So can we get it fixed soon?

Reported by shiyao.bao on 2015-04-07 21:05:33

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

There is nothing about opacity css property in section 10.1 of the current spec. So
it should not affect visibility of the element.

Prooflink: http://www.w3.org/TR/webdriver/#determining-visibility

Reported by Arikon on 2015-04-28 17:12:37

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I'm also facing this issue. Would be nice to resolve quickly.

Reported by kavin.ginige@clearpoint.co.nz on 2015-05-14 01:27:43

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Sending keys to an invisible input element is a special case so that you can upload
files in Selenium, even remotely if your tests are running in a Selenium Grid.

Since this is a special case for Selenium Automation (and the user isn't actually entering
text into a text field as such), I see no reason why we shouldn't fix the IEDriver
to support this.

Reported by bonnie.brown@jivelandia-qe.com on 2015-05-19 17:26:43

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

I set the input element visible via JavaScript, but still cannot upload file successfully.
After sendKeys(fileName) to the input, nothing responses. The Env is: Selenium 2.47+Safari7.
Would be nice to resolve it quickly.

Reported by xingjing2006 on 2015-09-01 09:37:16

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

#31

AFAIK only Chrome, Firefox and IE support file upload, not chrome.
If you are running your tests on a grid server, make sure you instantiate a FileDetector
before using sendKeys().

Reported by cleber.baldan on 2015-09-02 16:07:21

@lukeis
Copy link
Member Author

lukeis commented Mar 4, 2016

Reported by luke.semerau on 2015-09-17 17:47:04

  • Labels added: Restrict-AddIssueComment-Commit

@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant