title: Angular 6 - When testing file download with Protractor, how do I set a relative path for the file's destination
body: <p>I need to download a CSV and check its content in a Protractor test.  The tests are running as part of our deployment process, so the path of this download needs to be relative.</p>
  
  <p>Looking at other <a href="https://stackoverflow.com/a/26127745/4059156">solutions</a>, I have created a folder at /e2e called download and added this to my <code>protractor.conf.js</code>:</p>
  
  <pre><code>capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            args: ['--disable-gpu']
        },
        prefs: {
          'download': {
            'prompt_for_download': false,
            'default_directory': '/e2e/download'
          }
        }
      },
  </code></pre>
  
  <p>Here is the original test, which is clicking on a button to download the file and then checking the contents in my local Downloads folder (this needs to be changed once the download itself is actually working).</p>
  
  <pre><code>  it('should export the csv', () =&gt; {
      const filename = '../../../Downloads/new_Name_List_members.csv';
      const exportButton = testUI.findElementBy({findBy: 'buttonText', value: 'Export to CSV'});
      exportButton.click().then(() =&gt; {
        browser.driver.wait(function() {
          // Wait until the file has been downloaded.
          return fs.existsSync(filename);
        }, 5000).then(function() {
          expect(fs.readFileSync(filename, { encoding: 'utf8' })).toContain('username,email,name');
        });
      });
    });
  </code></pre>
  
  <p>Even though I've specified the path in <code>capabilities.prefs</code>, the file is still downloading to my local Downloads folder when the button is clicked.  Even if I set this to the full path---<code>'default_directory': '/Users/kkanya/Documents/Code/project/e2e/download'</code>---it still downloads to my local Downloads.  </p>
  
  <p>I've looked through the protractor <a href="https://github.com/angular/protractor/blob/master/lib/config.ts" rel="nofollow noreferrer">config.ts file</a> and can't spot anything that might allow me to change the default download directory.  In fact, I don't see a <code>prefs</code>, which leads me to believe this may not be the correct way to do it with the newest Protractor. </p>
  
  <p>Any help is much appreciated.</p>