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

file upload not stable in Internet Explorer #3858

Open
lukeis opened this issue Mar 3, 2016 · 27 comments
Open

file upload not stable in Internet Explorer #3858

lukeis opened this issue Mar 3, 2016 · 27 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3858

I have tests uploading a file that I run in multiple browsers (HtmlUnit, Firefox and
Internet Explorer). I use the following code:

File uploadedFile = new File("src/test/resources/" + fileName);
file.sendKeys(uploadedFile.getAbsolutePath());
submit.click();

Tests works fine in HtmlUnit and Firefox but often breaks in Internet Explorer. What
happens is that the file upload dialog is opened but nothing is entered in the file
input and the test hangs. 

I noticed few interesting things:
- When I run multiple tests that upload a file without closing the browser only the
first one will fail. When I close the file dialog manually during the first test the
next test will upload a file correctly.
- Opening the file upload dialog in Internet Explorer takes more time when done for
the first time after the browser is opened.
- It fails more often on a slower or busy machine.

Because of the reasons above I suspect that there might be insufficient waiting for
the file upload dialog to appear in Selenium before it tries to input the file path.

Selenium version: 2.21.0
OS: Windows 7
Browser: Internet Explorer
Browser version: 8 (8.0.7600.16385)

Reported by pioter.jagielski on 2012-05-06 12:38:02

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by barancev on 2012-05-06 17:28:14

  • Labels added: Component-WebDriver, Browser-IE

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I'm seeing seeing similar issues here with IE8, selenium 2.21.0 on win 7 64 bit.

Either nothing is happening after the file upload dialog has been opened (as described
above) or there is a popup saying "File not found" that blocks IE.

No such problems on IE7 and Firefox.

Reported by daniel.caminada on 2012-05-07 08:37:56

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I'm seeing this also. The file upload dialog is filled in correctly when I use Selenium
2.20.0, but fails with 2.21.0. The same test drives both cases; so it appears that
the issue was introduced by 2.21.0.

Selenium version: 2.21.0
OS: Windows 7
Browser: IE 9
Driving Selenium via Capybara

Reported by jRoush@ezpublishing.com on 2012-05-16 16:23:02

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Found this bug with IE9.
the way, that usualy give it:
run tests with RemoteWebDriver on Windows7.
But necessarily to run tests in parallel mode with another browser (Opera or Firefox).

This bug is stable with this way

Reported by rubtsova.evgeniya on 2012-05-30 11:40:45

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The same for me. Running tests in parallel with remoteDriver on v.2.21.0. Happens on
IE9. The browser upload window is open but does not close. This leads to the build
cannot be stopped. I think that it is a high priority issue, not the medium because
it blocks all next tests

Reported by lykvymolly on 2012-07-05 07:00:19

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue was closed by revision r17373.

Reported by barancev on 2012-07-09 16:10:03

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

@barancev: can you publish a new release with your fix? The current release 2.24.1 only
contains changes up to svn 17205.

Reported by erooolkoc on 2012-07-20 10:46:32

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The current is 2.25, which should contain the fix. 

Reported by james.h.evans.jr on 2012-07-20 12:42:05

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Yes, links on the main site are not updated yet, but 2.25 is available from [1]

[1] http://code.google.com/p/selenium/downloads/list

Reported by barancev on 2012-07-20 12:45:35

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Great, thanks!

Reported by erooolkoc on 2012-07-20 13:07:38

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I've been testing today with the 2.25.0 level and am still able to intermittently reproduce
this issue. I can however only reproduce the problem when running with Internet Explorer
8. Internet Explorer 9 seems to work fine - or my IE9 machine is faster than my IE8
machine and this changes the timing. Whatever the case I don't think this issue is
resolved.

Reported by darkalpha84 on 2012-07-24 13:39:53

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reopening

Reported by barancev on 2012-07-24 17:35:20

  • Status changed: New
  • Labels removed: Status-Untriaged

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

It works for our tests on IE7 (Windows XP) and IE8 (Windows 7), but fails on IE9 (Windows
7) using Selenium 2.25.0.

Reported by erooolkoc on 2012-08-08 07:41:09

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hi!

Is it still reproduced for last selenium version?

If yes please provide:
* executable test scenario
* public URL or HTML+CSS+JS pf page at which the problem is occured
* execption info
* TRACE log from IEDriverServer

Reported by a.u.savchuk on 2013-05-08 09:59:39

  • Status changed: NeedsClarification

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I have exactly the same problems with IE9 and IE10 (IE8 works fine). Selenium version
is 2.33.0. Everything works if I run tests directly from Visual Studio, but when I
let TFS build to run tests, all file upload tests are timing out. Selenium log contains
that kind of information:

D 2013-07-11 12:22:33:303 server.cc(239) Command: POST /session/9dbeec41-edfb-422a-bb10-bea13064292c/element/eb1f262f-eeb9-4545-bcef-8c836f7d7345/value
{"value":["C",":","\\","F","o","o"]}
D 2013-07-11 12:22:33:303 command.cc(33) Raw JSON command: { "command" : "sendKeysToElement",
"locator" : { "sessionid" : "9dbeec41-edfb-422a-bb10-bea13064292c", "id" : "eb1f262f-eeb9-4545-bcef-8c836f7d7345"
}, "parameters" : {"value":["C",":","\\","F","o","o"]} }
D 2013-07-11 12:22:33:303 IECommandExecutor.cpp(516) No alert handle is found
I 2013-07-11 12:22:33:303 Browser.cpp(99) No child frame focus. Focus is on top-level
frame
D 2013-07-11 12:22:33:324 Element.cpp(439) Element is a block element, using IHTMLElement2::getBoundingClientRect
D 2013-07-11 12:22:33:340 Element.cpp(517) Element is not in a frame
W 2013-07-11 12:22:33:355 Element.cpp(826) X coordinate is out of element area
D 2013-07-11 12:22:33:355 Element.cpp(285) Will need to scroll element into view
D 2013-07-11 12:22:33:355 Element.cpp(439) Element is a block element, using IHTMLElement2::getBoundingClientRect
D 2013-07-11 12:22:33:355 Element.cpp(517) Element is not in a frame
W 2013-07-11 12:22:33:371 Element.cpp(826) X coordinate is out of element area
W 2013-07-11 12:22:33:371 Element.cpp(305) Scrolled element is not in view
D 2013-07-11 12:22:33:371 Element.cpp(310) (x, y, w, h): -1028, 97, 1833, 40
W 2013-07-11 12:22:34:465 c:\projects\webdriver\trunk\cpp\iedriver\CommandHandlers/SendKeysCommandHandler.h(184)
No dialog directly owned by the top-level window
W 2013-07-11 12:22:39:824 c:\projects\webdriver\trunk\cpp\iedriver\CommandHandlers/SendKeysCommandHandler.h(204)
No dialog found

I guess that file upload dialog takes more than 1 second to open (see SendKeysCommandHandler::SetFileValue).
If the upload dialog is not opened fast enough SetFileValue returns false and webdriver
breaks. Increasing max_wait could fix the problem.

Test result contains this kind of error message: The HTTP request to the remote WebDriver
server for URL http://localhost:50748/session/f2a4e535-7b55-446c-9760-fcce1ca1413a/element/e5c8372d-eaf3-4f48-aa18-527a116c1e7f/value
timed out after 60 seconds.

Reported by lasse.kakkuri on 2013-07-11 10:15:02

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Wish this could be fixed soon! Very annoying problem that I had to create an elaborate
retry mechanism to work around...

Reported by arthur.blake on 2013-07-11 13:26:15

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Has anyone come up with a workaround to this problem? I'm thinking about using a separate
AutoIt process to dismiss the upload dialog manually (because if I'm sitting there
and manually dismiss it every thing works great). I tried upgrading from selenium 2.21
to the latest (2.38) but was met with a raft of other instabilities introduced. I think
once the team decided to go to Webdriver as a separate server process model, all kinds
of things broke and they are very slowly being fixed. Doesn't help that Microsoft is
now releasing major IE upgrades so quickly...

Reported by arthur.blake on 2013-12-10 12:59:44

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The same here with: Java WebDriver 2.37 + IEDriver 2.39 32bit + IE11. sendKeys() failed
with below exception:
Caused by: org.openqa.selenium.remote.UnreachableBrowserException: Error communicating
with the remote browser. It may have died.
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'hpswvm234185', ip: '16.153.234.185', os.name: 'Windows 7', os.arch:
'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:89)
at com.hp.systinet.qa.soa.proxy.ui.browser.SeleniumBrowser.sendKeysToElement(SeleniumBrowser.java:466)
... 41 more
Caused by: org.openqa.selenium.WebDriverException: java.net.SocketTimeoutException:
Read timed out
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:15:02'
System info: host: 'hpswvm234185', ip: '16.153.234.185', os.name: 'Windows 7', os.arch:
'amd64', os.version: '6.1', java.version: '1.7.0_51'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:75)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 44 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:281)
at org.apache.http.impl.conn.LoggingSessionInputBuffer.readLine(LoggingSessionInputBuffer.java:115)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:92)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:62)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:289)
at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:127)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:712)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:517)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:319)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:298)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:66)
... 45 more

Reported by ilynaf on 2014-02-18 09:52:58

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The exception mentioned in my previous comment only occurs if the file doesn't exist.
Once this happens, the execution could be hang for hours (6 hours in my case)

Reported by ilynaf on 2014-02-19 08:20:09

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

After upgrading to version 2.40.0 also IE8 broke. Before that file upload worked with
IE8, firefox and Chrome, but not with IE9 or IE10 (see comment #16)

Reported by lasse.kakkuri on 2014-03-04 12:19:54

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I am using  selenium 2.44 version .when i use sendkeys method with IE8 for click and
set file path in <input type='file'>,it works fine ,but same thing not working on IE9
& 10

Reported by katiyar.aditya14 on 2014-12-18 10:35:36

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I am also using the selenium 2.44 version . the sendkeys method does not work at all
with IE10 and IE11, so with version work fine

Reported by cartershaoping on 2014-12-31 08:14:41

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Hello,

I am also able to reproduce this in Selenium server 2.43.1 ane IE Driver 2.44.0

And am able to reproduce this issue in IE10 & 11....

Why is this issue still in "NeedsClarification"?

Reported by Development@Gandomi.com on 2015-02-09 14:27:44

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I have the same issue as these folks: IEDriver does not accept sendKeys() to a webelement
such as <input type="file">

This issue does get serious when people are unable to use WebDriver to run upload file
tests in IE running on nodes, such as BrowserStack or SauceLabs. This is my case.

Chrome and Firefox work fine using the setFileDetector() - see code below, but IE requires
to click on the input, which brings up a Windows file Dialog, not covered by any native
Selenium API that I know of. Thus, you can't handle this dialog on nodes.
Locally I was able to build a workaround using Java Robot class, which won't be executed
on the nodes.

Just to make very clear, the same code that works with multiple versions of Chrome
and FF does not work with any IE version I tested.

Since I have a BrowserStack account, I'd be happy to run tests in any Windows version
and IE combination that devs may need to investigate this issue.
Even tough I found a flaw, I'm still very greatfull for the work of the people involved
in the Selenium project.

My current setup is:
Windows 7 SP1 64 bits
IE 11
Java 1.8
Selenium 2.44.0
InternetExplorerDriver server (32-bit) 2.44.0.0

Code snippets

public class BusinessDetails extends Page {
    public static final By inputNewLogo = By
            .cssSelector("div > input[type='file']");
    public static final By divImageUploadSpinner = By
            .cssSelector("div.ember_loader_content");

    public void uploadValidLogo() {
        final String VALID_LOGO = "validLogo.png";

        uploadLogo(inputNewLogo, VALID_LOGO);

        getDriverProxy().wdWait.until(ExpectedConditions
                .invisibilityOfElementLocated(divImageUploadSpinner));
    }
}


public abstract class Page extends AbstractPage {

    public void uploadFile(By inputElement, String imageName) {

        if (ConfigurationProvider.isRunningOnGrid()) {
            ((RemoteWebDriver) getDriver()).setFileDetector(
                new LocalFileDetector());
        }

        String imagePath = Utils.getFilePath(imageName);
        if (!ConfigurationProvider.isRunningOnGrid() && Utils.isHostOSWindows()) {
            imagePath = imagePath.substring(1, imagePath.length());
            imagePath = imagePath.replace("/", "\\");
        }

        getDriver().findElement(inputElement).sendKeys(imagePath);
    }
}

Exception thrown:
(...)
2015-03-10 23:48:18,647 [Update_Business_Details_Valid_Logo] [ERROR] Test execution
FAILED
org.openqa.selenium.ElementNotVisibleException: Element is not displayed (WARNING:
The server did not provide any stacktrace information)
Command duration or timeout: 30 milliseconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8',
time: '2014-10-23 13:11:40'
System info: host: 'XXXXXXX', ip: '192.168.12.24', os.name: 'Windows 7', os.arch: 'x86',
os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=false, ie.forceCreateProcessApi=false,
ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11,
platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0,
ie.browserCommandLineSwitches=, requireWindowFocus=true, browserName=internet explorer,
initialBrowserUrl=http://localhost:7704/, takesScreenshot=true, javascriptEnabled=true,
ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true,
unexpectedAlertBehaviour=dismiss}]
Session ID: cfa81fae-4ea2-43b9-9e3a-69135462fe82
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_40]
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599) ~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:89)
~[selenium-remote-driver-2.44.0.jar:na]
    (...)

Reported by cbaldan@daitangroup.com on 2015-03-11 03:12:58

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I download the IEDriver 2.45.0 and tested with the same code I provided in the previous
comment, but the error is the same:

LOG:
(...)
Started InternetExplorerDriver server (32-bit)
2.45.0.0
Listening on port 12978
(...)
2015-03-11 00:19:05,298 [Update_Business_Details_Valid_Logo] [ERROR] Test execution
FAILED
org.openqa.selenium.ElementNotVisibleException: Element is not displayed (WARNING:
The server did not provide any stacktrace information)
Command duration or timeout: 22 milliseconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8',
time: '2014-10-23 13:11:40'
System info: host: 'XXXXXXXX', ip: '192.168.12.24', os.name: 'Windows 7', os.arch:
'x86', os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=false, ie.forceCreateProcessApi=false,
ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11,
platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0,
ie.browserCommandLineSwitches=, requireWindowFocus=true, browserName=internet explorer,
initialBrowserUrl=http://localhost:12978/, takesScreenshot=true, javascriptEnabled=true,
ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true,
unexpectedAlertBehaviour=dismiss}]
Session ID: 83d1d75a-8844-4c87-aa77-3eca1a53fe91
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_40]
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599) ~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
~[selenium-remote-driver-2.44.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:89)
~[selenium-remote-driver-2.44.0.jar:na]
(...)

Reported by cbaldan@daitangroup.com on 2015-03-11 03:23:04

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I am experiencing the same problem. It works fine with Chrome but not with IE and phantomjs.

Reported by sharathkonda on 2015-06-16 22:18:18

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 17:44:49

  • 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