Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
geeta.chaudhari
Posts : 1
Join date : 2011-12-09

Modal dialogs in webdriver Empty Modal dialogs in webdriver

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.

-Geeta
avatar
ccnnll
Posts : 6
Join date : 2011-12-03

Modal dialogs in webdriver Empty Re: Modal dialogs in webdriver

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?
avatar
veluruanil
Posts : 2
Join date : 2012-10-29

Modal dialogs in webdriver Empty Re: Modal dialogs in webdriver

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();
System.out.println(availableWindows.size());

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

Please help me on how to handle modal dialog boxes
avatar
ashish_techie
Amateur
Amateur
Posts : 73
Join date : 2011-08-09

Modal dialogs in webdriver Empty Re: Modal dialogs in webdriver

Wed Oct 31, 2012 12:47 am
Message reputation : 100% (1 vote)
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


Regards
Ashish

For selenium tutorials:
www.qtpselenium.com/selenium-tutorials
avatar
Love Sharma
Regular Participant
Regular Participant
Posts : 27
Join date : 2012-06-01

Modal dialogs in webdriver Empty Re: Modal dialogs in webdriver

Wed Oct 23, 2013 10:06 pm
Hi,
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.
avatar
mail2prassad
Amateur
Amateur
Posts : 41
Join date : 2013-06-05

Modal dialogs in webdriver Empty Re: Modal dialogs in webdriver

Thu Oct 24, 2013 7:48 pm
We can work with Modal dialogs with Webdriver.

Try this code

Webdriver Code
============

Code:
import java.util.Iterator;





import org.openqa.selenium.By;


import org.openqa.selenium.WebDriver;


import org.openqa.selenium.WebElement;


import org.openqa.selenium.ie.InternetExplorerDriver;


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


driver.get("http://localhost:8080/demo/1.html");





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


button.click();





Thread.sleep(1000);





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


String main = itr.next();


String popup = itr.next();





System.out.println(main);


System.out.println(popup);





driver.switchTo().window(popup);





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





}


}






1.html
=====

Code:
<html>


<head>


<script language="javascript">


function showPopup(){





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





}


</script>


</head>


<body>


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


</body>


</html>


2.html
======

Code:
<html>


<head>





</head>


<body>


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


</body>





</html>

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

We can see the values in console output
==============================
cba55042-31df-4f21-90ca-5a09c125b9c1
eed6279d-8e39-477b-b189-37505a177f53
Hello

Thanks,
Prassad.
avatar
Love Sharma
Regular Participant
Regular Participant
Posts : 27
Join date : 2012-06-01

Modal dialogs in webdriver Empty Re: Modal dialogs in webdriver

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Ā 
button.click();

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.
Sponsored content

Modal dialogs in webdriver Empty Re: Modal dialogs in webdriver

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