How to close framed pop up window with Selenium - java

I am trying to close popped up window of this page http://zerohedge.talking-forex.com/live.html
Does anyone know how to do that, well it is not easy obviously, but nevertheless anyone?
If selenium not powerful enought for that task, please recommend another tool.

The HTML you want to interact with is inside a frame (named 'content'). You need to tell selenium to switch to it. The following python code works:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://zerohedge.talking-forex.com/live.html")
driver.switch_to_frame("content");
driver.find_element_by_css_selector(".ui-icon-closethick").click();

...That should be fairly straightforward:
driver.findElement(By.cssSelector(".ui-icon-closethick")).click();

Related

Selenium WebDriver methods vs. JavaScript executor

I'm developing an application for automation of an upload process on a website. Right now it is working with Gecko Driver on Firefox but I want to change to HtmlUnitDriver. For this application I just started using Selenium. At the begin I just used methods on WebElements (e.g. click() ...). Then there was a difficult part where it doesn't worked out. After that I found the JavascpriptExecutor class. This class was the solution of my Problem. Now I am thinking about totally change from WebDriver Methods to JavaScriptExecutor. I think it will be faster and less error-prone. Am I right? Are there any disadvantages for me to change to JavascriptExecutor?
Thanks in advance.
For QA testing generally one should not use JavascriptExecutor.
Read more about Why using JavascriptExecutor in WebDriver can be dangerous.
But for getting stuff done and fast It is great!
Read more about What are the advantages of using a JavaScript executor in Selenium.
Hope this helps you!

How can I set selenium chrome driver typing speed?

I have a ui test that uses selenium chrome driver. I want to set the form filling speed to be slower. I have googled but couldn't see how.
Does someone know how to do this?
In Selenium 1 you can use setSpeed method, in Selenium 2 (aka WebDriver) is, unfortunately, no option like this, at best you can use Implicit waits. However is not really recommended to slow down the Selenium for all tests, you should add waits only for tests which really need to wait for some action to complete.

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();

Selenium RC not able to work with downloads popup window

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

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