How to Handle Browser Popup (During the Download) using Java - java

currently we scrap the data from Websites using Web driver (Selenium)with Java, during that Scrapping we need to do some download process (i.e XML file Download), let me know how will handle the Browser Popup (save As Dialog) using Java
<a href="javascript:downloadXML()">
<img width="40" height="20" border="0" name="imag34" alt="Download" src="/pair/img/tabs/downloadxml.gif">
</a>
We are using the following code to click the above image
driver.findElement(By.xpath("(//img[#alt='Download'])[3]")).click();
After clicking that image, it will open a "Save as.." popup. How do we go to that popup and do testing on that?

This download popup is basically a window.open Javascript call with the URL of the XML file.
So this seems to be the relevant link :
How to switch to the new browser window, which opens after click on the button?

I've just solved this problem using the Robot class from Java. The Robot class allow you to simulate keybord press, in so doing you can work with TABs and Enters in order to execute the download.

This is actually a windows pop up and firebug will not able to detect this.If you are using windows OS then you can use AutoIT tool this will solve your problem.

Related

Java Browser handle button click

I need to open a browser with URL and then wait till person clicks a special button. And if it happens, return true. Can I implement it with java tools or should I use javascript?
You should use JavaScript. Java is a Server side language, so all processing of Java code will be completed before the user has the chance to interact with the page. JavaScript (traditionally) works on the client-side and is commonly used to capture user interactions with the browser.
yes, Java Script or any frame work that builds on Java script like Jquery works for you. If understands you correctly,
create Hyper link
Browse the page that you needed
Place HTML button on the page, write onClick logic on that button to return true.

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.

None of the buttons(Save, Open, Cancel) attributes in IE developer tool not show up

Requirement is to download the Excel file from IE9 browser. I could able to click the Download button using Web driver in Java by which new window is displayed as shown below:
When I am trying to view the attributes of save button in IE developer tool, tool could not recognize them. Please help where is the problem with this window or how to resolve this issue.

How to control IE-hosted java applet programmatically?

I've got a need to navigate java-applet programmatically and I am not that keen on Java platform. So lets assume I've got IE process stated with appropriate java applet loaded. Next I need to have some actions taken to this particular applet, like, lets say, sending WM_COMMAND to dialog along with BN_CLICKED code like I do with Windows in C. Assuming it's not a regular window I can refer to using HWND, I would like to ask someone for recommendations on how to do this.
As I understand you want to navigate (sending keystrokes and mouse clicks) a java-applet on the client side. It depends if you own the applet (say: you have the code and can change it) or if the applet is closed source and you just want to remote it.
In the first case use javascript to automate it. Change the containing HTML page to include some Javascript and pass parameters to the applet as described in the Java Tutorials.
If the applet accepts parameters, but you cannot change the HTML page, use a GreaseMonkey alternative for IE.
Your other approach (sending Windows Messages from an extern application to IE) should also work. Start Spy++ (use the 64bit version if you are using a 64bit Windows), choose "Search - Find window..." and drag the "Finder Tool" icon over the applet and release it. You will see then the HWND and if you press search you will see the window inside IE window hierarchy. So, yes you can send keystrokes and mouse clicks to a browser.
If I would automate the browser I would use Geb. You code a "web site test" in Groovy, just look at the Geb index page.
You could try to record a navigation through the applet with FireFox + "Selenium IDE" then export it and try run it in a Java Application with the Selenium IE WebDriver.
Information about Selenium can be found here : http://docs.seleniumhq.org/
Maybe this question will also help you : How to automate Java applet?

Is there a way to load an applet in chrome extension?

I have written a class for my application and want to use it in making chrome extension.I tried loading applet in popup.but it seems that chrome has blocked applets. The functionality i want to embed is when user visits a page he sees a button on omnibox..when user clicks the button i want to send some page elements to my applet which processes it and saves it as a file in the filesytem. for this i want to dynamically add the applet to dom..or atleast if i can load the applet its fine!!
This is a known limitation between Java Applets and Google Chrome, for more information please refer to the following issue: http://code.google.com/p/chromium/issues/detail?id=30258

Categories

Resources