Modal dialogs in webdriver
+2
ccnnll
geeta.chaudhari
6 posters
- geeta.chaudhari
- Posts : 1
Join date : 2011-12-09
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
Has anybody successfully automated any application using modal dialogs using Webdriver?
Am badly in need of this solution.
-Geeta
- ccnnll
- Posts : 6
Join date : 2011-12-03
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?
- veluruanil
- Posts : 2
Join date : 2012-10-29
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
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
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
- ashish_techieAmateur
- Posts : 73
Join date : 2011-08-09
Re: Modal dialogs in webdriver
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
Regards
Ashish
For selenium tutorials:
www.qtpselenium.com/selenium-tutorials
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
- Love SharmaRegular Participant
- Posts : 27
Join date : 2012-06-01
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.
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.
- mail2prassadAmateur
- Posts : 41
Join date : 2013-06-05
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
============
1.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.
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>
======
- 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.
- Love SharmaRegular Participant
- Posts : 27
Join date : 2012-06-01
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.
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.
Permissions in this forum:
You cannot reply to topics in this forum
|
|