Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created February 23, 2014 10:20
Show Gist options
  • Save thekarel/9169612 to your computer and use it in GitHub Desktop.
Save thekarel/9169612 to your computer and use it in GitHub Desktop.
var util = require('util');
it('should upload file', function() {
var fileToUpload = '../some/path/foo.txt';
var absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);
$('#uploadButton').click();
});
@Lamerchun
Copy link

Hi, i get error path is not defined. Can you tell if i have to hook up some dependencies?

@Lamerchun
Copy link

Found out: your code has to be fixed.

var path = require('path');

instead of util.

@ralucasuditu
Copy link

hi, what represents "#uploadButton"?

@m-ajitabh
Copy link

Somehow like this.

@ralucasuditu: #uploadButton, this is an ID which represents Upload button.

var path = require('path');

it('should upload file', function() {
var fileToUpload = '../some/path/foo.txt';
var absolutePath = path.resolve(__dirname, fileToUpload);
$('input[type="file"]').sendKeys(absolutePath);

$('#uploadButton').click();
});

@SwetaGabani
Copy link

what is __dirname ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment