How to close the newly popup window in selenium webdriver - java

When I click on one button, it goes to another screen and one new popup window appeared. I don't know how to close. Can any one help me out this? Im using Eclipse for writing code.

If the child window is a HTML window then you can close the window by using driver.close() syntax. Here assume driver is instantiated properly.
If it is a Native or OS window then it is not possible to handle it through selenium.

Related

How to focus and interact with popup using selenide api

I have a popup screen (see attached image). I am using selenide which is a fantastic wrapper api of selenium. Can someone tell me how selenide focuses and interacts with such window popups.
I was able to get this to work. It was an Iframe and by using
driver.switchTo().frame("IFrameID/name") to interact with the popup window
To Go back to the main frame
driver.switchTo().defaultContent()

How can an applet be modal and keep IE9 window from closing?

I have a JAVA applet that brings up an application modal dialog. The problem I am having is that the user can close the browser (or tab) and the dialog will remain up. If you click on the IE9 window area or menu bar the dialog appears modal, but when you click on the tabs or the window's "x" button IE9 is not modal to the dialog. I have tried various forms of modality and none seem to make the entire window and dialog modal. I tried using a window listener in the applet, but it doesn't seem to get the closing message. If you close the windows this way, the java process does not properly shut down and you have to kill it via the task manager. I don't remember this happening with IE8. Is there any way to make the entire IE9 window and my dialog modal?
Prior to raising the java modal, could you communicate back out to the page via liveconnect javascript call, setting a function to window.onclose that either sets focus back on the applet or prompts the user via browser confirm or alert?
Upon closing/dismissal of the applet dialog, you could clear the browser window.onclose function pointer.
Hope this helps,
-Scott H

Modal page Automation using Selenium webdriver

I am using Java and selenium webdriver for WebAutomation. The scenario is like, when we click on the particular option the new Modal page gets opened. However, with help of Webdriver, when I click on that particular option the modal page is not getting opened. Please suggest me how can do this
It seems Click() is not happening on the Particular Option which opens up the modal page

Selecting an option in a CSS-based menu with WebDriver

I have a simple CSS-based dropdown menu, and I'm trying to click on one of the menu items in a Java Selenium (WebDriver) test.
Both the menu (<ul> element) and the items (<a>) have IDs and creating corresponding WebElement objects works fine. I'm trying to click on one of the items with code like:
hoverOver(transfersMenu);
transferLink.click();
In hoverOver(), I've tried all three answers from this question, but none of them work. I keep getting:
org.openqa.selenium.ElementNotVisibleException:
Element is not currently visible and so may not be interacted with
Command duration or timeout: 2.06 seconds
(I've tried calling transferLink.click() also before hoverOver(), in the hope that the implicit wait would make it work, but nope.)
Any idea how to make the hovering work so that the link can be clicked?
Selenium version 2.21.0. I'm running the tests on Linux (Ubuntu), using Firefox 13.0. A colleague just tried on Windows (using Firefox 12.0), and it didn't work for him either.
Update: As per Slanec's tip in comments, and these instructions, I tried setEnableNativeEvents(true) on the FirefoxProfile. At first this failed:
org.openqa.selenium.InvalidElementStateException:
Cannot perform native interaction: Could not load native events component.
...but after I upgraded to Selenium 2.23.1, I no longer get that complaint.
Still, the hovering doesn't work (with native events on or off). :-/
I use the following code to hover over our menus for 1 second, before clicking a link, just like the one you are using:
action = new SeleniumActionHelper(driver);
WebElement currentUser = findElementByLinkText("testing1");
action.mouseHover(currentUser);
Thread.sleep(1000);
Of note, the mouse cursor needs to remain in the browser window for the hover to keep. If the mouse cursor is outside of the browser window, I experience a quick flash of the menu, but it does not stay visible
Try this exampale:
WebElement menuHoverLink= driver.findElement(By.id("test"));
actions.moveToElement(menuHoverLink).perform();
driver.findElement(By.id("test")).click();
Thread.sleep(6000);
How do you run your test classes? I found out that running WebDriver through ANT makes hover actions impossible, whereas running the test classes from command line (TestNG JAR) or from Eclipse works just fine.

Java applet/dialog strange behavior

I have a non-trivial Java applet. It has a menu, and via that menu applet shows a dialog that extends JDialog. Dialog is shown using setVisible(true). When user finishes working with that dialog, dialog is closed (after pressing "done" button) using this.dispose().
Now, there's a strange problem - applet works fine in Firefox, even in IE but in Chrome, when applet shows some other (dialog) window, that window is shown behind the applet. I have to click on the place where dialog should be in order to show it (bring it to front). If I click it again (while it's shown) it will disappear (go to background) again. Button clicks are working as usual, but whenever I click at popup window itself (even it's title-bar) it changes it's "visible" state.
Please, any idea what's wrong? How to resolve that bug?
// the applet will typically appear inside a Window, get a reference to it using:
Window parent = Window.getWindows()[0];
// use the window as the parent of a modal dialog.
JDialog dialog = new JDialog(parent);
dialog.setModal(true);
// ...
dialog.setVisible(true);
// won't be called until the applet is dismissed
someJComponent.requestFocusInWindow();
Applets embedded in web pages will always be subject to modality and focus problems. For a better user experience, launch the applet free-floating using Java Web Start, or even better still, launch a frame using JWS.

Categories

Resources