I have to automate a case in which I have to download an excel file using selenium ide.I have done this in firefox by using custom profile feature which automatically download file and save it into a user defined folder. To do the same in Internet explorer, is there any thing in IE like custom profile and preferences? how do I prompt IE to automatically download a file..I am using java for automation..Kindly help..
No, you can't do it easily in IE, there's no profile to configure.
That said, you can try:
downloading the file directly using this (or any other similar WebDriver-friendly tool), if you can. That will totally cut IE out of the process.
see How to download and save a file from Internet using Java? about the same thing, just generic Java and not WebDriver.
if everything fails, you can try blindly pressing Enter after clicking the download, Robot helps with this. But you can't really specify the folder.
Related
I am trying to write a java program that uses selenium to perform web actions. In the case of uploading a video there is a frame where the user clicks that brings up the File Explorer for Windows. I have not been able to find anything that will help me in getting the focus to the File Explorer to select a file. There is no "browse" on the page with a textbox for me to just send a filename to.
Here is what the page looks like:
I would try using Selenide because it has a pre-canned upload utility that might save you some time/effort. See the command .uploadFromClasspath in the docs. One of the project videos/pages shows a little more detail on how to do it.
I've not actually tried it, but if this works for you and you figure it out, please share.
What I have done in the past is to use the "Apache HttpUtils" class to simulate the upload action from my test. All you need is the upload URL, and the HTML page usually provides that. That might also work for you.
I am trying to automate downloading files using selenium with chrome as my browser using chromedriver. When i try downloading exe files its prompting me "This type of file can harm your computer, Discard or save it". i want it to download anyway without any prompt.
I have looked into few solutions like below:
chromeOptions = webdriver.ChromeOptions()
prefs = {"browser.helperApps.alwaysAsk.force" :False,"browser.helperApps.neverAsk.saveToDisk" : "application/octet-stream"}
chromeOptions.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(executable_path=//path//to//chrome_driver, chrome_options=chromeOptions)
But this didn't help it still throws up the prompt.
Any help on this is greatly appreciated.
Thanks,
From what I understand, there is no way to tell Chrome not to warn on potentially dangerous binary file downloads, see:
ChromeDriver has no way to accept dangerous downloads (Archived)
Add option to automatically accept dangerous downloads (Wontfix)
As the simplest workaround, you might want to approach the problem with Firefox:
Also there have been numerous requests from dev community to allow to
disable this warning to be able to run automated tests in Chrome. At
the moment this is the only reason we're running our automated tests
in Firefox only. Really annoying.
Is there any way to download an applet embedded in a webpage of a site www.abc.com1, to one's system?
Or is it possible to extract its code for offline use?
E.G. http://www.falstad.com/dotproduct/
For the link provided, I see the link "Zip archive of this applet.". It contains the applet jar, html page and the java source file.
You can try to inspect the page source to see the archive file it is using. In this case, it appears as if it is using http://www.falstad.com/dotproduct/dotproduct.jar. You can use this in a project, but the source will not be attached.
The applet at http://www.falstad.com/dotproduct/ can certainly be used off-line. I tested it just to make sure.
You would need to download the dotproduct.jar (referenced in the page - are you familiar with "View Source"?) to the local file-system then create an HTML (or use a copy of Paul Falstad's own HTML) to launch it.
You might try "Save page as" for the 2nd part, but I am not confident that that would also download the Jar of the applet itself.
Of course, it would be courteous to let Paul know what you are doing. You might find he will be prepared to send you a Zip of the HTML/applet.
We're building an analytics portal, and needless to say, a top feature is the ability to export statistics to excel. My question is - Does Selenium provide the ability to detect the generation of Excel files (upon clicking the icon within the portal)?
At this stage, just the presence (or absence) suffices. I don't need to delve into the excel file contents (yet).
More information - Here is a screenshot of the excel file that is generated...
This notification seems outside Selenium's purview
The file download dialogs are part of the Windows Component Object Model (COM) and not the Browser, thus selenium won't be able to work with it. One of the best ways to handle it with a tool that can interact with the COM, such as AutoIt (mentioned in a comment above).
See this answer that contains example script to do what you want: how to handle IE Download dialog with VB Script? but instead of invoking AutoIt from VBScript you would invoke it with the code running selenium (but it will have to be on the local machine).
I'm trying to open a PDF file after I generate a report. I mean, the user logs in (it's a Swing-based app) and clicks to generate a report. Then, a PDF file is generated. I would like to launch the PDF reader at that moment. I could do something like exec("evince "+path_to_pdf_file). It's just for Ubuntu, Windows would be more difficult. I'm thinking I need to explore the registry.
How can I achieve this?
What you need is the method java.awt.Desktop#open
Launches the associated application to open the file.
If the specified file is a directory, the file manager of the current platform is launched to open it.