2

SO, I'm trying to download a file into a specific directory while using Selenium with nodeJS to trigger the download. Here is the code I have to click the button itself:

const chai = require('chai');
const expect = require('chai').expect;
const assert = require('chai').assert;
var webdriver = require('selenium-webdriver'),
    By = webdriver.By,
    until = webdriver.until;
var driver = new webdriver.Builder()
     .forBrowser('chrome')
     .add_argument("")
     .build();

driver.get(url);

driver.sleep(2000).then(function() {
    driver.getTitle().then(function(title) {
        expect(title).to.equal(title);
    });
});
driver.sleep(2000).then(function() {
    driver.executeScript('window.scrollTo(0,10000);');
    driver.sleep(300);
    driver.findElement(By.className('button col-md-2 download-button')).click();
}) 

My issue is that Selenium and the web driver seem to download into a unknown/inaccessible location. If anyone knows how to solve this issue if would be appreciated.

Chrome Driver Version = 2.32.498537 
npm Selenium-Webdriver Version = 3.5

1 Answer 1

2

You need to set the download location by doing something like:

var webdriver = require("selenium-webdriver");
var chrome = require("selenium-webdriver/chrome");
var options = new chrome.Options();
options.addArguments(“download.default_directory”,”/path/to/download”);

var driver = new webdriver.Builder()
     .forBrowser('chrome')
     .withCapabilities(options.toCapabilities())
     .build();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.