Selenium RC not able to work with downloads popup window - java

I am new to the selenium RC. I have been working in eclipse to run a simple junit test case to run and download flashplayer from adobe.com.
But the selenium RC is not able to click or even recognise the downloads pop up window. I have been seeing several suggestions in google search but still I am not able to do it.
I have been trying to get the window ID or name of the pop up window to work with it, but still I am not able to do it. I have copied the major function of my code here down below:
public void testPopup() throws Exception
{
selenium.open("http://get.adobe.com/");
selenium.open("/flashplayer/");
selenium.click("id=buttonDownload");
String ids[]=selenium.getAllWindowIds();
for(int i=0;i<ids.length;i++)
System.out.println(ids[i]);
String[] windownames=selenium.getAllWindowNames();
for(int i=0;i<windownames.length;i++)
System.out.println(windownames[i]);
String feedWinId = selenium.getEval("{var windowId; for(var x in selenium.browserbot.openedWindows ) {windowId=x;} }");
System.out.println(feedWinId);
selenium.chooseOkOnNextConfirmation();
selenium.waitForPageToLoad("30000");
}
It will be great if someone can help me out with this.
Thanks

The short answer: you can't.
The longer, but still disappointing answer:
You can't, because no current Selenium implementation supports it. The Selenium people know about it, it's actually nr. 13 in most wanted features in Selenium right now
Selenium RC will never have it because of its technical limitations (It's pure JavaScript. And pure JavaScript can't download and save files.) and it has been deprecated over a year ago. Selenium WebDriver ... well, maybe, in the future. The various things you can try instead:
Rethink whether you really need to download the file. Isn't is ok just to assert that the file exists and can be downloaded by making a HTTP request and seeing that the answer was 200 OK?
Can't you download the file using pure Java after you get it's URL via Selenium? I personally think this is the best way to go.
If you're using WebDriver, there is a great tool for downloading files!
If you're using Firefox, you can set up a clean testing profile that will be configured so that it will download every clicked file into some specified folder. There are addons out there that can help you with it, too. I'm not sure whether Selenium RC supports usign a precreated profile, but Selenium WebDriver definitely does.
If you're using one given browser to do your tests, you can figure out how to download a file "blindly" by pressing buttons blindly. The Robot class can help you with that. You just click the file and then blindly press Enter or whatever keys to download your file into the right place. There is also AutoIt framework which a lot people use for this task.

You can not automate system generate pop-up by using selenium.
For that you have shift over Autoit with selenium.
With the help of this you can records your activities on download pop-up

Related

Java - Go to new url in new window/tab

I want to be able to use Java to tell it to go to X url when X browser is open/running (my lingo is terrible). (Firefox/Chrome/IE is already up, and I want it to go from the default page to let's say Twitter.)
Most of the solutions are using java.awt.Desktop to launch native browser with a url in it, but that isn't useful if I want to change the url later on. (Already on Twitter-Home Page, but want to go to Twitter-Contact Us afterwards.)
The other solutions I've seen involve using Selenium WebDriver, but I also need to eventually learn how to basically force the Java to read a long list of URLs off an excel and simply verify that url isn't dead, and then do this on the Native Android browser, for example. So the Selenium might not be the right choice. Granted, you can also tell me this is an awesome choice for this too if it truly is. I haven't really been exploring Selenium.
Sorry for asking such a basic question. Company wants QA Automation without training/hiring an Automation QA. My end goal (aside not getting canned), is to see if I can get a bunch of urls to load on specific browsers. I can sort of (praying) be able to do stuff with it afterwards.
A simple trick would be to create an add-on( if you know javascript ) which will be quite similar in chrome and firefox (for IE I have no idea in my days it needed BHO) and send websocket commands from java to your addon. But this needs a java websocket server running where your addon will connect when the browser opens. Rest of communication can be carried upon the protocol lines of your requirements.
There are multiple parts to your question.
Read urls from excel.
Use Apache POI to do the same. Selenium code can use the same.
Check that the urls are not dead.
Use any java http client, (apache) to do that without even opening a browser. If the link is dead, it will be dead for all the browser.
Open the links in a multiple browsers.
Selenium is perfect for this. I am assuming that after the page is loaded you have way of validating that the page is correct. Selenium is very powerful here.
Target native android browser too.
I do not know of much difference between this and the previous question unless you are also testing site display based on browser size. The browser is more or less the same as chrome with webkit rendering engine.

Detect what element was clicked with JAVA

For the project in my school I am creating a automation tool for the web with JAVA.
This tool should detect the user activity on web page, save it, and then run the result as Tests.
I found solution for the running part: I will use Selenium to run all the tests that I am automatically generating.
But I did not found how to detect user activity on the web, Selenium can do it?
The Idea is to check what element the user was clicked, hover, send keys...
There is a way do detect what element was clicked in the browser with pure JAVA? if not, there is some tool to check it?
Look at the Selenium IDE plugin for Firefox. It will help record your usage of a website. You can then reuse the scenario to perform your test.
Since the tests are actually made on the front-end, the tests are not tied to Java. Your back-end could be written in C# or PHP: the front-end user has no idea what's behind.

How best should I interact with Flash from Selenium Java WebDriver

I am aware a bunch of similar questions such as (Interact flash elements using WebDriver) have been asked in the past however it is still not clear how best to interact with a Flash Element on a page in association with Selenium's Java WebDriver.
By default I know it doesnt support Flash, so I use it to log onto the site which is fine. Now I need to interact with a flash element as seen on this page :
http://store.nike.com/us/en_us/product/free-tr-4-id/?piid=34979&pbid=517639039
I want to be able to pick a shoe size from the Flash on the left hand side of the page, and then click the add to cart button.
Can anybody who has achieved this please offer their guidance and opinion on the best way. I have tried https://code.google.com/p/flash-selenium/ however this appears to be old, or not compatible with the new Java WebDriver.
The answer to your question is: No, there is no way you can interact with Flash from/using Selenium WebDriver. Full stop.
I know there are heaps of developers out there need to automated Flash. But this has never been a part of the Selenium project and it will never be added into. You might want to have a wander around Selenium Users group.
For projects like flash-selenium and flex-ui-selenium, they are not part of the Selenium project but created by third party, which means they can easily be discontinued due to various reasons. If you have decided to use them, you might end up developing the project itself instead of using it. Furthermore, I'm not aware of such projects compatible with Selenium WebDriver anyway.
One other possible solution might be using Sikuli, which is not a Flash automation tool though. It should support automating Flash with its unique image comparison technology. But once again, this has nothing to do with Selenium in any way.
There is a massive misconception that webdriver cannot interact with flash elements.The answer is YES you can interact with flash elements embedded inside html if you can locate the xy coordinates you can interact using selenium ACTION class like so..
Actions Action = new Actions(driver);
WebElement e = driver.findElements(By.cssSelector("button"));
Action.moveToElement(e).clickAndHold().perform();
Action.release().perform();

How to move iMacro script to Selenium?

We have been using iMacro for our QA Automation, at a recent discussion it was decided to shift to Selenium.
Selenium provides a comparison thus neglected to mention how to migrate scripts to their platform..http://wiki.imacros.net/Selenium
is there any tools available for this purpose?
There is currently no tool that I know of that can help you with this.
There a couple of alternatives for migrating from iMacros to Selenium:
If you have a small amount of scripts re-record them using selenium IDE
If you have a large amount of test you could write a script that can map equivalent commands, you may still need to do some manual clean up but it may at least save you some time.
The easiest way (if you are using firefox) is to select Tools->Selenium IDE. This will open Selenium IDE in a separate window. Use the Imacros sidebar to "play" the script while Selenium IDE is recording. I just did this myself. It works like a charm. Obviously, this won't do any Imacros specific text-scraping, but if your script is a simple set of actions it works fabulously.

How do get Java to drive/control webkit/gecko?

I want to be able to have Java to control a webkit/gecko/konqueror browser.
The Java should be able to do things like "go to this url; give me the DOM tree; simulate mouse click / keyboard input on blah".
What is the easiest way to do this? There seems to be some half-working solutions on the web, but no one true open source project.
What have done in situation? (I have to use Java; but the engine I control is open to choose).
Thanks!
I am not sure what exactly you need to do, but Selenium Remote Control works with Firefox, IE and Safari.
With it, you can write Java code like the following
selenium.open("/");
selenium.type("q", "selenium rc");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("Results * for selenium rc"));

Categories

Resources