This is the path of file

 capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {

            prefs: {
                download: {
                    'prompt_for_download': false,
                    'directory_upgrade': true,
                    'default_directory':  'src/test/javascript/e2e/downloads'

I download the file with this,


It downloads the file, but I am not able to check if it was downloaded. It has only count in name, so I can check if it contains count.

After all is done I will delete files, so only those files will stay after I download.

I did lots of things but could not manage.

Also, another way is if service is sending 200 response. But i think it is harder to do?

Please suggest me


You can do it.

The idea is to clean up the download directory before the test and use glob.sync() function continuously called inside a browser.wait() Expected Condition.

The complete code:

var glob = require("glob");

browser.driver.wait(function () {
    var filesArray = glob.sync(filePattern);
    if (typeof filesArray !== 'undefined' && filesArray.length > 0) {
        // this check is necessary because `glob.sync` can return
        // an empty list, which will be considered as a valid output
        // making the wait to end.
        return filesArray;
}, timeout).then(function (filesArray) {
    var filename = filesArray[0];
    // now we have the filename and can do whatever we want

You just need to define a filePattern - the glob file pattern to match your file - it can be *.* if you don't want to be specific. Or, for example, it could be *.xls if this is an Excel file.

Also see:

  • Message: Failed: Wait timed out after 18167ms Stack: Error: Wait timed out after 18167ms at process._tickCallback (internal/process/next_tick.js:103:7) From: Task: <anonymous wait> – mark Jan 3 '17 at 11:48

The response code is not possible. Explanation.

But you can solve your problem using count pattern. The idea is to skip files in the target folder which you know are not your downloaded file before the test. Keep all its names in a list. After the download, fetch the names of the files in the folder and check if the difference in size is equal to 1 - and that the name of this new file contains count in its name.

If you run another tests before cleaning the folder, add this new file folder to the skip files names list that you created at the start.

  • i also want to do those check but i dont know how to do. if i can do, i will get the size of of folders inside that download folder then after downloaded, check again to compare if +1 – mark Dec 15 '16 at 18:32
  • Just to make explicit: What I mean by folder is size is the number of files inside it. Here you can found out how to do it in Java: stackoverflow.com/questions/4362888/… – João Farias Dec 16 '16 at 19:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.