Selenium Automation + chromedriver - selenium

I am trying to automate a web application wherein clicking a link downloads a PDF file. The default behavior of chromedriver should open a pop-up window for confirmation. I am facing issue with the same, In my case the file is directly downloading without prompting.(I need to pop up to change the file name)

My understanding is that there is no easy way to make Selenium download files. Browsers use native dialogs which cannot be controlled by JavaScript.
Why are you downloading a file in the first place?
Check out this for more detail.

This can be set via settings option,
refer the below link https://support.google.com/chrome/answer/95574

Related

Selecting a file in MacOS Finder when running Selenium / Capybara test script

I'm attempting to upload a file on a page that I'm testing. The attach_file method within Capybara will not work here. The reason being that the upload feature is using a JS library named file-uploader here.
I'm actually able to invoke a mouse click in order to open a Finder window (in Mac OS) to allow me to select a file to open, however I'm not sure of how to work within this window. Essentially I'd like to select a file from my desktop and just click 'Open'.
Is there a way for me to work within this window to simply choose a file by its name and then click 'Open'?
I'm working in Firefox.
Dragging the file from my desktop into a div would also work, but I can not find a way to do that in Capybara either.
Thank you.
Selenium is a browser automation tool & as such any interaction with other components of operating systems is not possible. Once a browser opens a file open/Finder window, it's no longer the browser that you're interacting with. There are tools out there which can handle them, but i am not familiar enough to give a detailed response. Google the Robot framework, or AutoIt for starters.
Alternatively, since it's a JS library you're dealing with which handles the upload, you MAY be able to use the JavascriptExecutor to call library functions directly, which doesn't simulate the user experience, but may be enough to get past your hurdle.

How to handle download dialog using Selenium IDE?

I have a web page which contains a download link. If I click on the link, download dialog window will be launched and asking save or cancel.
If I click on Save, file will get downloaded, it will be closed if I click on Cancel button.
But, Selenium IDE is capturing any actions performed in the dialog window.
Please tell how to handle this situation using Selenium IDE.
Thanks in advance.
Unfortunately save as dialogs cannot be interacted with via javascript so Selenium IDE can't manipulate them.
If you want to click on a link and download a file, you can set up Firefox to automatically save files (without dialog - http://kb.mozillazine.org/File_types_and_download_actions). At lease with this method you can save the file when running localy.
The limitation of this will be that if you wanted to export the selenese and run it on an external testing solution (Saucelabs or Testingbot) it is unlikely that this approach will work.
You can also modify the firefox profile in the setUp method of your test.
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword,application/csv,text/csv,application/rtf,application/xml,text/xml,application/octet-stream,application/vnd.ms-excel,application/zip,text/txt,text/plain,application/pdf,application/x-pdf");
If you have other types of documents you want to download you should look up the MIME type of whatever document you are trying to download and adding it to the comma delimited list.

Automate File Upload using Selenium Webdriver C# on ASP.NET file upload control

I have a ASP.NET file upload control which opens a window when you click the upload button to select the file you want to upload. But the problem is that the webdriver cant recognize the window and therefore cant select the file to be uploaded.
I have found numerous solutions in the stackoverflow which use sendkeys to enter the path of file. I think that works when you have html file upload control. In my case I have the ASP.NET file upload control and it doesn not have a text box where i can enter the file path using sendkeys.
how do i solve this?? Any suggestions ?
You can use the Windows Automation library to identify windows. UIspy can be used to identify the properties of a window. Add the System.Windows.Automation reference to your project.

Selenium- Issue-Clicking on windows pop-ups

I am using selenium to record some tests. We have a save to pdf button on our application that generates the windows open/ save or in firefox the ok/cancel windows pop up,
The issue is that i can;t get selenium to record my ok or cancel action since i think it is not a javascript window?
Does anyone know the command to do that?
thanks
Sadly, it's not possible to interact with such windows at the moment.
A good workaround for saving files dialog is to save the various parameters (local directory, etc) and tell your browser to not prompt for them, so the window won't pop at all.
See http://wiki.openqa.org/display/SEL/Selenium+Core+FAQ#SeleniumCoreFAQ-Whatyoucan%27tdowithSelenium
Create a separate firefox profile(command to open profile manager:-firefox -P) with the settings you want(you can give settings like where to download and save a file of a particular type automatically without prompting) and instruct your server to use that profile using the command : java -jar 'your server ' -firefoxProfileTemplate 'path_for_firefox_profile'

Control Download confirmation popup window using selenium script

I wrote test case to click on download button. How to go to download confirmation pop up window and select save or open option, and click ok and come back to main window. I am using selenium-python script for web test automation.
Selenium can't control the download confirmation. It can, however, type a file path directly in to the file upload field if you're using a "privileged" browser mode for IE or Firefox. If you're using the default *iexplore and *firefox modes with Selenium RC 1.0 beta 2, try simply type a file path directly in to the form field. I do this myself and it works great.
I think this question has been answered here before and the answer is using another tool for automating the browser's dialog e.g. autoit
How do we download a file by using Selenium?
you can switch the on the Pop-Up and confirm it, but I don't know to manage if....
Try that:
alert = browser.switch_to_alert()#switch to popup
alert.accept()#accept popup