Taking control over window pop up to save a .zip file - java

How to take the control on window popup for saving a .zip file in window machine for firefox in java with selenium web-driver.

We use a Robot class for this purpose (java.awt.Robot).
http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html

Related

Application closes immediately after launch on one PC, but works fine on another

I've developed a Automation Project using Selenium, Java and Netbeans. Now, I must deliver it to my client. I've used the option "Clean and Build" on Netbeans for building the jar
When I launch that jar file on my laptop:\
Opens JFrame form.
Where I enter few fields and press Start ! button
It opens Chrome Browser using (chromedriver) and browse sites and save result in excel file
Although when I've tried it on another laptop (for testing purpose before sending it to client)
Opens JFrame form.
Where I enter few fields and press Start ! button
It opens Chrome Browser using (chromedriver) but immediately closes itself within second.
ERROR : https://ibb.co/k1NH7Bd
Is this information enough to solve my problem or I must provide more information as well. Looking Forward to hear from you guys.

How to close dialog by Selenium?

I want close browser file window pop-up (when I upload picture to Wordpress).
I tried
driver.close();
driver.findElement(By.id("set-post-thumbnail")).sendKeys(Keys.ESCAPE);
driver.switchTo().alert().dismiss();
but it doesn't work. How to close dialog by Selenium?
OS Specific dialogs like File Browser can not be controlled by Selenium.
It can handle only WebElements or JavaScript/Browser Alerts.
In this specific case, I think it is upload file browser.
Workaround may be to pass the absolute path if some text input field is provided along with "Browse" button.

Highlighting the same explorer windows on explorer /select command

We use explorer /select command with the file path to open the file in windows explorer. https://support.microsoft.com/en-us/kb/152457 But on multiple invocations it opens a new window everytime. I am invoking the command from a java application using the process runtime APIs.
is it possible to have one window being opened ?. For e.g. if an explorer with c:/A is being opened ,repeated invocation of the same command must open the same window which is opened. ?
cheers
Saurav
It seems that your problem does not have a simple solution.
According to my understanding the "window sharing" of expplorer is not the explorer's feature. Please take a look on the following article: https://support.microsoft.com/en-us/kb/241911
(Although this article is talking about Internet Explorer I guess it is relevant for file exploerer as well).
According to my user experience the window sharing happens only when you are getting to directory via some kind of shortcut and does not happen when you are running explorer explicitly. For example if you type in "run" window "explorer" the new window is always created, however if you type "c:\" the window will be re-used.
You want to execute explorer with specific option, so you have to run it explicitly, therefore no window re-use can be achieved.
But I can suggest you 2 workarounds.
Do not use /select option. "Run" the base directory of the file you want to select. This will guarantee the window reuse. Then "select" file using java.awt.Robot by "typing" its name.
Manage the opened Explorer windows yourself into your java application. You can store map of file-to-exploerer window handler. When application wants to run open explorer for file that is already selected in other explorer window, activate it. To do this you need some JNI/JNA code. Take a look on the following discussions for details.
In Java Swing how do you get a Win32 window handle (hwnd) reference to a window?
Find out what application (window) is in focus in Java

swt browser diplays pdf in new window

I'm experiencing a strange issue with the SWT browser widget.
I developed a multipage application using the "transition composite" widget from opal widgets.
In my last window I need to display a pdf.
I've been looking for free open source solutions on the web, and the only one I could fine was IcePdf but the renderization of the page was not great.
Then I found out I could use the browser widget to diplay a pdf.
I created a new project with the following code :
shell = new Shell();
shell.setSize(l, h);
Browser browser = new Browser(shell, SWT.NONE);
browser.setBounds(xb, yb, lb, hb);
browser.setUrl("file://" + pdfPath);
and it worked great.
But then if I run the same code in my actual application, it opens the pdf into adobe reader and not into the application itself.
Has anybody else noticed that issue before? And if yes how can I solve it?
Thanks in advice,
Stefano Franchini
I think there is an internet explorer or adobe reader setting which needs to be changed.
This might help:
If you want the browser to open PDF files in a separate Acrobat window, configure the browser to use Acrobat or Adobe Reader as a helper application. Then, when you select a PDF file in Internet Explorer, the browser will open the PDF file in an Acrobat window instead of the browser window.
To configure the browser to use Acrobat or Adobe Reader to open PDF files:
Quit Internet Explorer.
Start Acrobat or Adobe Reader.
Choose "Edit" > "Preferences."
Select Internet in the list on the left.
Deselect "Display PDF" in Browser, and click "OK."
Restart Internet Explorer.
Note: The next time you select a link to a PDF file, the browser may prompt you to open or save the file. If you choose to open the file, the browser opens the file in the helper application that you specified. If you choose to save the file, the browser downloads the file to the hard disk.
https://helpdesk.egnyte.com/hc/en-us/articles/201637224-How-Do-I-Open-PDF-Files-in-Adobe-and-Not-Internet-Explorer-
A different IE setting resolved this for me when running Eclipse 2019-03 and OpenJDK 11 (64-bit) on Windows 7:
Open Internet Explorer
Settings>>Manage add-ons>>Toolbars and Extensions..
Find the menu under Show in the lower-left, change to All add-ons
Find Adobe PDF Reader under the Adobe Inc. section, near the top of the right-hand pane
Change the Status from Disabled to Enabled
Hit Close button
Then try running your SWT Browser instance again with the browser.setURL() as the absolute path of the PDF file to be shown. Don't forget to call browser.update() after setting the URL/path so the SWT component is re-rendered.
(I know, it's been years on this question but I just ran into it and figured out a new solution which I could not find elsewhere on SO, so wanted to capture this in the hopes of helping someone else who might come across this issue in their work).

Focusing on an external java window? WINDOWS

I'm using a robot to click on a certain point on the screen. I just need a way for the robot to bring the desired window to focus. Now here's where the real problem lies, the window is a Java window, but not one I made. I used a VBscript to focus on Firefox earlier, but I'm not sure what to do. When I mouse over the icon on my toolbar, it says the windows name is "BitMinter Client v1.4.2" but in Task Manager it calls the process "Java(TM) Platform SE binary (32 bit)?
How do I focus in on the window?
Having the robot input ALT+TAB won't work because the window isn't second on my ALT+TAB list.
AppActivate looks for matching Window's titles.
Use spy++ (Windows SDK and most MS development tools) to get the window title.
You mention firefox so I don't know what type of Window you are referring to. In IE most web page elements (and for that matter very many other Window's things) haven't been Windows for decades. I don't know how firefox or java are implemented.
Windows basic architecture is windows (such as edit controls/buttons) inside other windows (a pane) inside a top level window (ie notepad) inside the desktop window.
To take notepad. There is a main window, menu bar, statusbar window, edit control window. Each of them has a title and class. This is notepad's title and class.
Untitled - Notepad Notepad
«No Window Text 0» Edit
«No Window Text 0» msctls_statusbar32

Categories

Resources