Display results as :

Rechercher Advanced Search

Latest topics
» Selenium WebDriver Integration
Yesterday at 1:06 pm by azharuddin

» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce


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