Skip to content

Drivers should throw "invalid argument" error on an attempt to click file input #4843

Closed

Description

@jiteshsojitra

Selenium leaves control after clicking to file explorer Browse button in MS Edge. This works fine in Chrome and Firefox but absolutely blocking to run next step in the code. I tried code via all possible ways and below code works to click to Browse button but after this step selenium leaves control because file explorer window opens. Is this Selenium or MS Edge driver issue?

Environment:
Selenium version - Latest 3.6.0
Browser - MS Edge
MS Edge Driver - Latest Release 15063
Application type - Ajax web

Steps:
1. Open ajax web application through MS Edge (works)
2. Click to browse button through web driver core or java script method (works)
3. Selenium gone, leaves control till we close file explorer button (doesn't work) - this works fine in GC and FF.
4 (Blocked). Send key to type file name or implement AutoIt script (works)
5 (Blocked). Click to open button via AutoIt script (works)
6 (Blocked). File attached fine (works)

Working code:
driver.findElement(By.id("browseID")).click();
And
WebElement we = null;
((JavascriptExecutor)ClientSessionFactory.session().webDriver()).executeScript("document.getElementsByName('browseName')[0].click()", we);

selenium or ms edge leaves control

This is actually blocking attachment functionality and it would be great if selenium will fix this. So far i just see Autoit is the solution as a 3rd party software but it is very tedious to add separate scripts for every browse buttons in the application, any code by selenium blocks due to OS dialog appearance. Anyone faced this issue?

Activity

  1. barancev commented on Oct 10, 2017

    @barancev
    Member

    Don't click file inputs, just sendKeys to them.

  2. jiteshsojitra commented on Oct 10, 2017

    @jiteshsojitra
    Author

    Sorry but its not good to close the major issue like this where execution gets blocked. There must be some issue from Selenium or MS Edge driver side which needs to be put on attention to them.

  3. barancev commented on Oct 10, 2017

    @barancev
    Member

    It's not an issue, but intended behavior. To enter a value to a file input one have to sendKeys to it. Click to a file input raises a native file selection dialogue that can't be handled by selenium.

  4. jiteshsojitra commented on Oct 10, 2017

    @jiteshsojitra
    Author

    This is working fine in Chrome and Firefox so i'm pretty sure this is an issue with MS Edge. Please re-read the issue.

  5. barancev commented on Oct 11, 2017

    @barancev
    Member

    You're right, I was too hasty closing the issue. But I have to reframe it.

    In original Selenium API it was implicitly prohibited to click file input fields, behavior was undefined, and drivers could autoclose file selectoin dialogue, or block on it, any behavior was "allowed".

    But W3C WebDriver standard is mode definitive, it says "If the element is an input element in the file upload state return error with error code invalid argument." [1]

    None of the drivers implemens this requirement yet. So I'll reopen this issue on legacy Firefox driver and IE driver developed by Selenium team. And I'll raise new issues on other drivers in the corresponding trackers.

    [1] https://w3c.github.io/webdriver/webdriver-spec.html#element-click

  6. changed the title [-]Selenium leaves control after clicking to file explorer Browse button in MS Edge[/-] [+]Drivers should throw "invalid argument" error on an attempt to click file input[/+] on Oct 11, 2017
  7. barancev commented on Oct 11, 2017

    @barancev
    Member

    Test for this feature: d48e75b
    Legacy Firefox driver: 0e680bc

  8. KS261187 commented on Dec 22, 2017

    @KS261187

    I tried passing in the send keys and still it leaves the browser open. I can use autoit for the file upload control but it is getting timed out, since it is not leaving the control on sendkeys.

  9. ChintanShahX commented on Jul 5, 2018

    @ChintanShahX

    Any update on this issue? or any workaround that can be used for Edge browser

  10. barancev commented on Jan 26, 2021

    @barancev
    Member

    According to the current test status it's fixed in both Firefox and Chrome drivers.

  11. locked and limited conversation to collaborators on Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions