If the pop-up displayed in the browser opened by the "WebDriver" is colorful, we can't move it and also we can't inspect it then it is a hidden pop-up.
It is created by the developer by using driver, by default it will be hidden. It will be made visible whenever it is required by changing value of display property from none to block. Since hidden division pop-up is a part of web page only so we don't use switchTo() to identify the buttons present on the hidden division using findElement() only.
The pop-up which is displayed when we enter the URL(http://192.168.1.1) which will ask for authentication(User name & Password). When we specify the URL for "get()" it will try to open that web page where it will display the page on load pop-up. Till we enter the user name and password and click "OK" the page will not be loaded and get() will not allow us to execute any other statement.
In order to handle page on load pop-up we specify the user name and password as a part of URL itself:
WebDriver driver = new FireFoxDriver();
Handling File download pop-up
Web driver will not identify the file download pop-up and we can't perform any operation on the file download pop-up but by writing the code we can change the setting of Mozilla Firefox so that it will not display the file download pop-up instead of that it will save the required file in specified location.
Steps to change the setting manually:
Open Mozilla Firefox browser.
Type above:config in the address bar.
Then click on I will be careful, I Promise.
In the search field type "Save to disk" which will display the following preference "browser.helperApps.neverAsk.SaveToDisk". Double click it which will display a pop-up where we can change the setting. It accepts a string value which is of type "MIME"(Multipurpose Internet Mail Extension).
Child browser pop-up
If the child browser is displayed in order to perform any operation on the child browser we need to make the web driver to switch from parent browser to child browser.
In order to do this we use "driver.switchTo.Window()" which takes window handle of the child browser. In order to get window handle of the child browser first we get window handle of all the browsers using "getWindowHandles()" of WebDriver.
After switching to child browser if we use any method such as findElement(), close() etc, it will be executed on the child browser. If we close the child browser then we must switch back to parent browser by specifying window handle of the parent browser as a argument to "driver.switchTo().window()".