FuckTheWorld / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

File upload mimetype validation fails for csv #915

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Basically the problem seems to be that Chrome webdriver does not assign the 
right mimetype to csv files during Selenium tests. This causes my jQuery file 
validation to fail, even though the exact same file works during manual tests, 
and the test passes with the Firefox webdriver. (I would be happy to be proven 
wrong, though, with another root-cause provided).

What steps will reproduce the problem?
1. Have file validation using jquery-validation library (available here: 
http://jqueryvalidation.org/). Restrict file extensions and mimetypes to csv. 
Code below:

$(document).ready(function() {
    'use strict';
    $('#grade_form').validate({
        rules: {
            grade_file: {
                required: true,
                extension: "csv",
                accept: "text/csv,text/comma-separated-value,application/vnd.ms-excel,application/vnd.msexcel,application/csv"
            }
        }
    });
});

2. Using Selenium and Chromewebdriver, attempt to upload a csv file to that 
input.

    file_input = self.browser.find_element_by_id('grade_file')
    file_input.send_keys('/<FULL_PATH>/grades_deid.csv')

    grade_form = self.browser.find_element_by_tag_name('form')
    grade_form.submit()

3. Receive error about incompatible mimetype during test. Test fails / 
times-out waiting for next step

What is the expected output? What do you see instead?
File should upload and test should continue. This works just fine in manual 
tests using Chrome 29.0.1547.57 and the same csv file.
Instead, during the test, the input gives me an error (see attached 
image)--Please enter a value with a valid mimetype. This also works fine using 
the Firefox webdriver...

Selenium version: 2.35.0
OS: Mac OSX 10.8.4
Browser: Chrome, Firefox
Browser version: Chrome 29.0.1547.57, FF 23.0.1

Also cross-posted on SO: 
http://stackoverflow.com/questions/18496597/selenium-error-with-javascript-file-
upload-validation. Thanks for your help and any insights!

Original issue reported on code.google.com by faren...@gmail.com on 28 Aug 2013 at 9:21

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by barancev on 28 Aug 2013 at 9:37

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:18

GoogleCodeExporter commented 9 years ago
Issue is reproducible with chrome: 41.0.2272.76 and chromedriver:2.14. But when 
tried to select file manually, issue is not reproducible

please have below java code:

WebDriver driver=new ChromeDriver();
driver.get("evalidatetest.html");
driver.findElement(By.id("grade_file")).sendKeys("TestCsv.csv");
driver.findElement(By.tagName("form")).submit();

Original comment by ssudunag...@chromium.org on 12 Mar 2015 at 4:49

Attachments:

GoogleCodeExporter commented 9 years ago
I've run into this problem myself in my selenium tests. I believe that the 
error is caused by the fact that chromedriver assigns the mime-type 
'application/octet-stream' to every file that it uploads, so your application 
will not be getting the mime-type that you expect it to.

Original comment by szh...@narrativescience.com on 13 Apr 2015 at 4:23

GoogleCodeExporter commented 9 years ago
I'm supporting the Selenium2Library for Robotframework and a user reported this 
issue to me as well. They reported the same behavior on Chromium 41.0.2272.76 
(webdriver 2.15) and google-chrome-stable 42.0.2311.135-1 (webdriver 2.15).

Original comment by zephr...@gmail.com on 28 Apr 2015 at 10:19

GoogleCodeExporter commented 9 years ago
same problem is happened on latest chromedriver 2.15

Original comment by liuyu...@gmail.com on 25 May 2015 at 4:36

GoogleCodeExporter commented 9 years ago
This issue happens due to devTools DOM.setFileInputFiles

Original comment by gmanikp...@chromium.org on 26 May 2015 at 11:30

GoogleCodeExporter commented 9 years ago
Is there any workaround for this issue?

Original comment by rwat...@netflix.com on 29 May 2015 at 3:29

GoogleCodeExporter commented 9 years ago
I also receive this problem when using ChromeDriver to upload a .doc or .docx. 
Chrome cannot seem to detect the correct mime-type of the file so is using 
application/octet-stream

Original comment by ily...@gmail.com on 14 Jul 2015 at 12:28