Hi my selenium chromedriver in node automatically downloads files. I want to disable automatically downloads,
therefor I found many threads for python with a solution to set download_restrictions to 3, but in JS is no experimental settings I guess, and userPreferences seems to be the wrong place.
Someone know how to disable automatically downloads in a headless chrome in node.
Src: Disable all downloads with ChromeDriver and Selenium
https://chromeenterprise.google/policies/?policy=DownloadRestrictions https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup
my example code, download directory seems to be working
import { Builder, Capabilities } from 'selenium-webdriver';
import * as Chrome from 'selenium-webdriver/chrome.js'
export async function getDriver() {
const service = new Chrome.ServiceBuilder("./selenium/chromedriver");
const chromeOpts = await new Chrome.Options()
.addArguments("--disable-infobars")
.addArguments("--headless")
.setUserPreferences({
"download_restrictions" : 3
})
const driver = new Builder()
.withCapabilities(Capabilities.chrome())
.setChromeService(service)
.setChromeOptions(chromeOpts)
.build();
return driver;
}
const driver = await getDriver()
driver.get("http://www.africau.edu/images/default/sample.pdf")