Display results as :

Rechercher Advanced Search

Latest topics
» why do i get this error
Sun Apr 23, 2017 9:43 pm by anbarasi

» wait property
Sun Apr 23, 2017 12:50 pm by anbarasi

» What is the use of Selenium Remote Control
Fri Apr 21, 2017 7:24 pm by azharuddin

» How can I fix it? TCP PORT Exhaustion
Wed Apr 19, 2017 3:29 pm by JohnSnow

» Difference between QTP, Selenium and Silk test
Wed Apr 19, 2017 2:30 pm by Basilios Will

» Locator for google document
Tue Apr 18, 2017 10:01 pm by SergeyK

» I encountered a mistake: Couldn't register this node
Sat Apr 15, 2017 9:06 pm by skyshine725

» Current version tutorial for just creating a browser instance - Visual Studio
Fri Apr 14, 2017 2:47 am by KilpAr

» cant able to select drop down otions
Thu Apr 13, 2017 6:08 pm by anbarasi


Modal dialogs in webdriver

View previous topic View next topic Go down

Modal dialogs in webdriver

Post by geeta.chaudhari on Fri Dec 09, 2011 12:19 pm

Hi all,

Has anybody successfully automated any application using modal dialogs using Webdriver?

Am badly in need of this solution.



Posts : 1
Join date : 2011-12-09

Back to top Go down

Re: Modal dialogs in webdriver

Post by ccnnll on Tue Dec 20, 2011 1:47 am

I have to a limited extent - I've been able to get the title of the modal and click the cancel or continue button (that's all I've needed to do) but it took me a while to get the xpath right to hook into the elements. Can you describe what you are trying to do?


Posts : 6
Join date : 2011-12-03

Back to top Go down

Re: Modal dialogs in webdriver

Post by veluruanil on Tue Oct 30, 2012 12:24 pm

Hi all,

I have a scenario where when we login with temporary password, a modal dialog box appears asking to reset the temporary password. When i try to automate the scenario my script is unable to identify the web elements in the dialog box which has 3 text boxes, two button Update Password and Cancel.

i have tried various ways like:

1) driver.switchTo().defaultContent(); -- to switch to the modal dialog box

2)Set availableWindows = driver.getWindowHandles();

This prints as 1 saying we have only one dialog box.

Please help me on how to handle modal dialog boxes


Posts : 2
Join date : 2012-10-29

Back to top Go down

Re: Modal dialogs in webdriver

Post by ashish_techie on Wed Oct 31, 2012 12:47 am

There are various modal dialogs..

If its a lightbox then you will get xpaths and you can work
If its a windows authentication panel then you can use auto-it
Modal dialogs are not popups . they are part of same window


For selenium tutorials:


Posts : 73
Join date : 2011-08-09

Back to top Go down

Re: Modal dialogs in webdriver

Post by Love Sharma on Wed Oct 23, 2013 10:06 pm

I am facing same problem with modal dialogs. When we open it, webdriver just losses it's control and it hangs without any error.

control does not even move to execute next statement of code and just nothing happens further.

Love Sharma
Regular Participant
Regular Participant

Posts : 27
Join date : 2012-06-01

Back to top Go down

Re: Modal dialogs in webdriver

Post by mail2prassad on Thu Oct 24, 2013 7:48 pm

We can work with Modal dialogs with Webdriver.

Try this code

Webdriver Code

import java.util.Iterator;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;


import org.openqa.selenium.remote.DesiredCapabilities;

public class Example {

public static void main(String[] args)throws Exception {

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();

capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

WebDriver driver = new InternetExplorerDriver(capabilities);


WebElement button = driver.findElement(By.xpath("//input[@type = 'button']"));;


Iterator<String> itr = driver.getWindowHandles().iterator();

String main =;

String popup =;




System.out.println(driver.findElement(By.xpath("//input[@id = 'mytext']")).getAttribute("value"));






<script language="javascript">

function showPopup(){

window.showModalDialog('2.html','','dialogWidth:500px;dialogHeight:100px; resizable: no; status:no; return true;')





<input type="button" value="click" onClick="showPopup();"/>








<input type="text" id="mytext" name="mytext" value="Hello" />



Deploy 1.html and 2.html in demo webapplication and try running the webdriver code.

We can see the values in console output



Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Modal dialogs in webdriver

Post by Love Sharma on Thu Oct 24, 2013 9:13 pm

Thanks very much Prasad.
Can you also try to open 3,htm by clicking on button appearing in 2.htm?
It should open 3.htm at the top of 2.htm

Basically I tried your code but problem with webdriver is that when you click onĀ;

just above thread.sleep(10000), webdriver looses control over modal dialog window. I am not able to click on button appearing in 2.htm file to open 3.htm

Please suggest on this.

Love Sharma
Regular Participant
Regular Participant

Posts : 27
Join date : 2012-06-01

Back to top Go down

Re: Modal dialogs in webdriver

Post by Sponsored content

Sponsored content

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum