What is the best way to download a file without interference from automated

I am currently working on automating tests for some websites using WebDriver, TestNG, and Java code. I have encountered a challenge with downloading files. Specifically, I am trying to download a file from the following link:

http://www.labmultis.info/jpecka.portal-exdrazby/files/catalog_documents/index.php?id=43756

The code snippet below is not functioning properly, and I am hesitant to resort to using robots as it may not be an ideal solution.

        FirefoxProfile prof = new FirefoxProfile();
        prof.setPreference("browser.download.dir","C:\\Users\\...");
        prof.setPreference("browser.download.folderList", 2);
        prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf");

Additionally, manually selecting the checkbox to automatically download files like the one shown in the image below is not a feasible option moving forward:

http://s4.postimg.org/cnrxal2ql/download.png

If anyone has any advice or suggestions on how to resolve this issue, I would greatly appreciate it. Thank you.

Answer №1

Here are some recommended settings to try:

profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.manager.showWhenStarting", false);
profile.setPreference("browser.download.dir", yourFolderPath);
profile.setPreference("browser.download.downloadDir", yourFolderPath);
profile.setPreference("browser.download.defaultFolder", yourFolderPath);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk",
    "text/plain,text/csv,application/comma-separated-values," +
    "application/vnd.ms-excel,application/pdf,application/msword,image/svg+xml,*/*");
profile.setPreference("pdfjs.disabled", true);
profile.setEnableNativeEvents(true);

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Loop encountered an error: element reference is no longer connected to the page document

I wrote a script to retrieve the product links from the main page of an online store, and then iterate through each link to extract information about each product. Interestingly, the script works flawlessly during the first iteration (opening the product ...

Store extracted list data as a new column in a pandas dataframe

I am facing the challenge of scraping text from webpages and inserting it into a pandas dataframe. While I have no trouble scraping tables, this particular page does not have a table, causing me much difficulty. driver = webdriver.Firefox() driver.get(&ap ...

Encountering problem "Class not found in classpath" while using selenium

Currently, I am studying Selenium and while attempting to run the program below, I encountered an error stating "Cannot find class in classpath:practiseAutomation". The code is as follows: public class practiseAutomation { public WebDriver driver; String ...

Transferring authentication tokens from Google login using Scrapy Splash to Selenium

I need to access my Google Account and activate a Google API to retrieve the developer's key. My goal is to automate this entire process. It's common knowledge that logging into a Google Account using an automated browser is not possible. Howeve ...

Python script is not launching Electron and Vuejs application using selenium for end-to-end testing

I need assistance with conducting end-to-end testing for an Electron app using Selenium and Python. To set up a sample app in Electron and Vue.js: npm install electron --save-dev npm install -g @vue/cli vue create new-app vue add electron-builder To ...

What is the best way to reconnect with a JSON file?

pDialog = new ProgressDialog(NewItemList.this); pDialog.setMessage("Connecting..."); pDialog.setIndeterminate(false); pDialog.setCancelable(false); pDialog.show(); initiateJsonCall(); } public void initiate ...

Tips for choosing and utilizing a Modal form with Java for data input

I am currently testing the login functionality on the website using Selenium WebDriver in conjunction with Java. The implementation follows the Page Object Factory design pattern. To initiate the login process, I navigate to the specified site, click on ...

Parsing JSON data from an HTTP POST request in Java

How do I properly unmarshal a JSON file with this structure? { "packageId": "11", "jsScript": "var divideFn = function(a,b) { return a/b}", "functionName": "divideFn", "tests": [ { "testName": "test1", "exp ...

Manipulating strings by extracting a targeted statement

Is there a way to extract just the link from each line in order to get the desired output? For example, starting with this input: "url": "https://i.ytimg.com/vi/XGM6sHIJuho/hqdefault1.jpg", "og:image": "https://i.ytimg.com/vi/XGM6sHIJuho/hqdefault2.jpg" ...

Building pdftk on CentOS (Redhat) with /libgcj.so.10 integration

Is anyone able to build pdftk with the /libgcj.so.10 library successfully? Bluehost upgraded from centOS 5 to centOS6 and removed the library I was using, saying this is the new one. I checked the makefiles (Makefile.Redhat, Makefile.Base, and the java Mak ...

Automating SAP Fiori with Selenium (JAVA): A Step-by-Step Guide

Looking to automate SAP Fiori (Browser) using Selenium in Java. Are there any external tools that need to be installed or specific SAP configurations that need to be enabled in order to successfully read elements within the Fiori interface? Attempts have ...

Uncovering Secret Information with Beautiful Soup 4

I've hit a roadblock with my current project. I'm attempting to extract player names and projections from this website: The plan involves running a script that loops through various PID values, but that part is not causing any issues. The real c ...

Capybara gaining access to a single session simultaneously from two separate threads

Currently, I have a Ruby script that utilizes Capybara with the Selenium Chrome driver. The script navigates through a website, and at some point, an unexpected notification pops up that needs to be dismissed. I am wondering if it's feasible to imple ...

Using compound class names is disallowed - Java Selenium

I need help locating the following button, which is an ant controller. <li class="ant-picker-ok"><button type="button" class="ant-btn ant-btn-primary ant-btn-sm"><span>Ok</span></button></li> ...

When it comes to web scraping, what is the preferred choice: using selenium alone or combining it with beautifulsoup?

For my current project working with Python 3.6.3, bs4, and Selenium 3.8 on Win10, I am faced with the task of scraping pages that contain dynamic content. Specifically, I need to extract numbers and text from websites like . It seems using requests+beautif ...

Guidance on selecting a checkbox with a dynamically generated identifier using WebDriver

I'm facing an issue with a form that contains a checkbox. The id of the checkbox changes every time a new form is opened, making it difficult to identify and interact with using Selenium-Webdriver in C#. Is there a way to locate and click on this dyn ...

Having trouble with Selenium Chrome Webdriver in C#?

options.AddArgument("--disable-gpu"); driver = new ChromeDriver(options); driver.Navigate().GoToUrl(""); string currentDay = DateTime.Today.DayOfWeek.ToString(); ...

Mastering the art of typing authentically like a human using ActionChains' key_down and key_up

I am developing an online automation tool. However, this specific website evaluates the user's typing speed, causing issues with input commands. The error message is triggered by two factors: the timing of key presses and releases. This means that th ...

Can npm be integrated into a Java project?

I was eager to streamline some tasks for a java application by utilizing npm scripts. After creating a start script that triggers ant, makes changes to the dist/ directory, and launches three instances of the app concurrently using concurrently, my script ...

Interference from Modal Overlay Disrupts functionality of other Links on Shared Page

My primary webpage consists of multiple links, including one that triggers a modal when clicked on. This modal opens on top of the main page, allowing me to compare expected and actual links. However, I encounter difficulty in comparing the rest of the lin ...