Many application has some pop up for display some success or failure message to user. We need to handle that types of pop up in script.
There are three types of pop Up.
Web based pop up can be handle using WindowHandle or SwitchToFrame command. First we need to identify type of pop up.
If pop up is other window than we need to use WindowHandle command.
If pop up is just frame than we need to use SwitchToFrame command.
Using WindowHandle
Using SwitchToFrame
How to handle Alert Message
Po pup type is alert then we have to use Alert class for handle alert.
you can use object of alert class for different operations on alert like accept, dismiss, get alert text etc.
How to handle Windows based pop up
Selenium can not handle window bases pop up. Selenium only handle things which are based on web. There are many ways to handle window based pop up.
We can use AutoIT third party tool or Robot Framework for handle window based pop up.
Please visit below post for how to handle windows based pop up (dialog box) using AutoIT.
How to Automate Non Browser Based Functionality with Selenium + AutoIT
There are three types of pop Up.
- Web based pop up
- Alert message
- Window based pop up
Web based pop up can be handle using WindowHandle or SwitchToFrame command. First we need to identify type of pop up.
If pop up is other window than we need to use WindowHandle command.
If pop up is just frame than we need to use SwitchToFrame command.
Using WindowHandle
String vBaseWindowHande = driver.getWindowHandle(); Set<String> vWindowHandles = driver.getWindowHandles(); for(String temp : vWindowHandles) { driver.switchTo().window(temp); } // Code for Popup driver.close(); driver.switchTo().window(vBaseWindowHande);
Using SwitchToFrame
String vBaseWindowHande = driver.getWindowHandle(); driver.switchTo().frame("Name of Frame"); // Code for popup driver.switchTo().window(vBaseWindowHande);
How to handle Alert Message
Po pup type is alert then we have to use Alert class for handle alert.
you can use object of alert class for different operations on alert like accept, dismiss, get alert text etc.
Alert alert = driver.switchTo().alert(); alert.accept(); alert.dismiss(); String vAlertText = alert.getText();
How to handle Windows based pop up
Selenium can not handle window bases pop up. Selenium only handle things which are based on web. There are many ways to handle window based pop up.
We can use AutoIT third party tool or Robot Framework for handle window based pop up.
Please visit below post for how to handle windows based pop up (dialog box) using AutoIT.
How to Automate Non Browser Based Functionality with Selenium + AutoIT
No comments:
Post a Comment