title: Selenium: after file upload can not get file size
body: <p>I use Selenium to test web app behaviour on file upload page. 
  The goal of test is to check application validations on file selection.</p>
  
  <p>I use <code>webDriver.SendKeys</code> (C#) on file input to simulate file upload, file is selected successfully, but <code>fileInput.files[0].size</code> (js) is always 0 (or undefined?) and app shows error "Do not upload empty files". File size is correct on manual testing.</p>
  
  <p>Any suggestions, on how to solve the problem?</p>
  
  <p><strong>UPDATE</strong> Code details:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;input id="file-path" type="file" data-bind="attr: { accept: mimeTypes }, event: { change: onFileSelect }" /&gt;
  &lt;small id="file-path-error" class="field-validation-error" data-bind="validationMessage: file"&gt;&lt;/small&gt;
  </code></pre>
  
  <p>JS (file edit model uses knockout)</p>
  
  <pre><code>this.file = ko.observable().extend({
      validation: [
        {
          validator: function(file) {
            // valid if no file or file size &lt; 5Mb
            return !file || file.size &lt; 5242880;
          },
          message: 'File size should be less than 5Mb'
        }, {
          validator: function(file) {
            // valid if no file or file size &gt; 0
            return !file || file.size &gt; 0;
          },
          message: 'Do not upload empty files'
        }
      ]
    });
  this.onFileSelect = function(model, event) {
      var fileInput;    
      fileInput = event.target;
      if ((fileInput.files != null) &amp;&amp; fileInput.files.length &gt; 0) {
        _this.file(fileInput.files[0]);          
      } else {
        _this.file(null);
      }
    };
  </code></pre>
  
  <p>C#</p>
  
  <pre><code>webDriver.FindElement(By.Id("file-path")).SendKeys("C:\testFile.txt");
  Assert.AreEqual(webDriver.FindElement(By.Id("file-path-error").Text,"");
  </code></pre>
  
  <p>Assertion always fails because file-path-error contains "Do not upload empty files" - that is the problem.</p>