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).
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 displaying a list of files; i.e. xls, doc, pdf, odt etc., in my Java application (Eclipse RCP). When the user clicks on the file, I want to launch the appropriate (according to what the OS thinks) native application, just like it happens in Windows Explorer or the Finder.
And while I am here: It would be nice to also display the same icons that Finder or Explorer use for the different file types.
Is there a library or Eclipse plugin for this?
What you want is java.awt.Desktop:
Desktop.getDesktop().open( file );
I have found an API in Eclipse's SWT now that seems to do the trick:
org.eclipse.swt.program.Program "provides access to facilities for discovering operating system specific aspects of external program launching."
It has methods to find the program for a given file extension, get the program's icon, and even launch the program.
Sounds like you're after the Java Activation Framework ("JAF"). This API lets you determine what files are and what actions you can do on them. Or alternatively the Java Desktop Integration Component ("JDIC"). JDIC allows you to create and no doubt query file associations.
Both projects seem to be in a semi-abandoned state howeer (sigh). But that's par for the course for Sun these days. Only other thing I know of is some Windows specific third party library that's based on JNI called Winpack. It does a bunch of other things too.
You can get the associated icon using the FileSystemView class (Java 1.4+).
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.
I'm looking at all possible languages to solve a particular business case problem.
Basically need a way to allow user to browse for an excel file locally, then using Microsoft Excel COM automation, read in the cell contents and from this point on perform some actions.
I have no experience with Java, but I know this type of thing is "almost" possible using Silverlight 4.0. Here is a line of code that demonstates how you begin automation in silverlight using c#:
dynamic objExcel = AutomationFactory.CreateObject("Excel.Application");
Problem is Silverlight only opens files from "My Documents", and it seems there is nothing you can do to allow the app full access to the file system to read in any file. So I'm investigating if Java is capable of this task?
I don't need a big explanation on how to do it, mainly I just need your experience as a Java developer to say - Yes in principle its certainly possible, or not. I need to open this xls file from any location the user specifies.
So 2 things really:
Can you browse and open any file using a trusted java applet? And get access to the files path from the open dialog?
Can you automate MS Word / Excel from a Java applet.
Thanks
..Silverlight only opens files from "My Documents", ..
Java will not be able to break that security restriction.
It is for the benefit of the end user, in that if they truly want to edit the Excel file, they will save or move it to My Documents. If they cannot do that, then perhaps they should not be altering the file.
I need assistance finding a delivery method that best fulfills the following requirements:
We wish to deliver a single file to my clients.
Clients should be able to launch this file from the operating system shell - much like running an '.exe' on Windows.
After being launched, the program/script should be able to display a window with HTML content. this may be done using a stand alone program, a runtime or by running within a browser.
We need the ability to embed a resource within the delivered file, such as an mp3 file, which i can later extract programmatically.
Optimally, the solution should run on Windows, Mac and Linux machines. Less than perfect cross-platform interoperability is acceptable, but we want as broad a penetration as possible.
Clients should not need to pre-install anything (unless it is done transparently), pre-configure anything, or approve any thing for this to happen.
For example:
We could use a regular executable file, written in C++ to do this, but it will not be cross-platform.
We could use a sliverlight XAP file, an adobe Flex file or a Java JAR, but internet explorer warns users when local content is launched. In addition these approaches mean that we have less than perfect penetration, even though it is acceptable in these cases.
We could use a python (or equivalent) script, but the installed-base (penetration) of the python interpreter is not good enough.
Using a standard HTML is not enough because of the difficulty of embedding resources in it. Embedding Silverlight XAML or uuencoded content in HTML causes IE to display a warning.
Using something along the lines of a jpeg as a delivery method is not rich enough since we need to display HTML.
..but internet explorer warns users when local content is launched..
I don't get it, what's the problem with IE saying "Hey this app is trying to run your files!"
I don't mean you don't have a good reason for this, it is just, I don't get it.
IE will only warn the user if the app has not been downloaded and try to access local resources, for instance if running from an applet or a JNLP like this one:(click on the first orange button you see )
But if the users download the jar and run it from the computer ( double click on it ) the app is local and can run without problems.
The jar file is a zip file after all, so you can attach your mp3 file with it. Double click is supported in the desired platform, and the HTML content could be either a local file ( un-packed along with the mp3 file ) or an internet web page.
Java is preinstalled on those OS already.
"internet explorer warns users when local content is launched"
There's a reason for this. How can they distinguish your excellent, well-behaved, polite application from a virus?
Since the line between your app and a virus is very, very blurry, go with any of Silverlight XAP file, an adobe Flex file or a Java JAR.
The IE business is a good thing, not a bad thing.
You could try using the 'Jetty' application server.
This supposes there is a working java environment on the target machine.
Jetty is java servlet container but it is possible to configure
everything (web server, html templates, applications, etc.) in a
single executable jar, which launches the web server and opens a default page.
Exactly how the jar file is launched will vary from platform to platform
but otherwise the user interface will be identicle, and, as its a java application
you can do pretty much anything one it has started.
Sounds like MIME HTML does exactly what you want - unfortunately, it is not supported by many browsers other than IE.
I'd investigate Adobe AIR. It can display both HTML and Flex content in a desktop application without using a web browser. However this will require installation of the AIR runtime, also I'm not sure if the Linux version is out of the beta stage.
http://www.adobe.com/products/air/
You can also use a binary for each platform.
As per your description the app is very simple, and porting from one platf to another sounds like just matter of re-compile and offer binary based on the dist.
Is this an option?