THE ABOVE SOLUTION IS IN PYTHON BUT I AM writing code in C#!!! There is an icon on my application to download a .ini file. Through research the only solutions are in python and ruby but I am using c# with selenium. I have scoured google and stackoverflow but there is no solution! When I click the icon I get the following message:
"This type of file can harm your computer. Do you want to keep the ahdsfhewf.ini file anyway" Then it gives you a choice Keep or Discard.
How can I get rid of this chrome pop up in my code? And also confirm its downloaded?
I have tried this code but it doesn't work:
var options = new ChromeOptions();
options.AddUserProfilePreference("safebrowsing.enabled", false);
options.AddArgument("--safebrowsing-disable-download-protection");
I have also come across this code in python so if someone can convert it to c# this would be great:
print('Starting..')
prefs = {
'download.default_directory': 'C:\\Users\MainDesk\Downloads',
'download.prompt_for_download': False,
'download.extensions_to_open': 'xml',
'safebrowsing.enabled': False
}
options = Options()
options.add_experimental_option('prefs',prefs)
browser = webdriver.Chrome(options=options, executable_path='C:\\chromedriver.exe')
Again this looks promising but I need it in c# not python
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
prefs = {
'download.default_directory': 'C:/Utility/Downloads/',
'download.prompt_for_download': False,
'download.extensions_to_open': 'xml',
'safebrowsing.enabled': True
}
options = webdriver.ChromeOptions()
options.add_experimental_option('prefs',prefs)
options.add_argument("start-maximized")
# options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--safebrowsing-disable-download-protection")
options.add_argument("safebrowsing-disable-extension-blacklist")
driver = webdriver.Chrome(options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get("http://www.landxmlproject.org/file-cabinet")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[text()='MntnRoad.xml']//following::span[1]//a[text()='Download']"))).click()
First I don't want the pop up and secondly I want to confirm its downloaded.