Can anyone let me know how to download a word file using selenium(java)? My below code is not working.
FirefoxProfile prof = new FirefoxProfile();
prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/word");
When I click on 'download link or icon' in the page, it prompts a popup to save the download file (see image below) and I need to click on OK
button in the popup.
Please let me know how to do this using Firefox.
New Selenium IDE We can download any file and save it to the desired location with Selenium. This can be done by creating an instance of the FirefoxOptions class. Then with the help of the addPreference method, we have to set the browser preferences.
The most basic way of uploading files in Selenium is using the sendKeys method. It is an inbuilt feature for file upload in Selenium. The syntax is as below: WebElement upload_file = driver.
Alert printDialog = driver. switchTo(). alert(); printDialog. dismiss();
Try this
import java.awt.Robot;
And use
Robot r = new Robot();
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
This will press Enter Programatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With