Hello!

I have recently been testing. Actually, bypassing the entire Internet, I just can’t ensure that when I run the test, the window with the option "save or open file" does not pop up when the test references it. As I understand it, using Selenium webdriver you cannot achieve clicking on the "OK" button in the browser window. You can only configure automatic download. PDF file. In the settings of the browser it does not help. Could you suggest any possible options? I would be extremely grateful.

Java test

  • The ok button should have focus by default, so you can click on it with java.awt.Robot. - Andrew Bystrov

2 answers 2

I see 2 ways:

  1. Create a browser profile, set it up so that it automatically saves files:

    profile = webdriver.FirefoxProfile(profilePath);

  2. Load the required browser settings when launching selenium. Find exactly which fields in about: config are responsible for automatically saving to a category, and then when launching the Selenium browser in the necessary test, load these changes.

This is done in the following way (this is just an example, you need to change to the appropriate fields and values ​​for your needs):

 FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.startup.homepage", "http://www.google.com"); driver = new FirefoxDriver(profile); 

Personally, I would try the second way first, and if it doesn't work (it is quite possible), I would go first.

    I decided this in this way: create a profile (firefox), configure autosave without confirmation to the correct folder, when creating a driver, specify the path to the profile:

      profile = webdriver.FirefoxProfile("c:/Users/User1/AppData/Roaming/Mozilla/Firefox/Profiles/qo8hmyya.eqrn") 
    • Have you tried this option? - Senior Pomidor