1) First of all , you have to check the element which you want to automate is in the tag <iframe>. If the element is in tag <iframe> then you can follow the steps:
First of all take the index of all the frames present in your current open browser tab. And then use the method driver.switchTo().frame()
which will take index of your targeted frame and then will switch control to the targeted frame
2) Now if your element is not in tag <iframe> then it means it is simple popup window and you can select that element by following way
2.1) if there are multiple popupwindow open then use follwoing steps
1st take the window id using
main browser window id you can take using mehtod driver.getwindowhandle();
and remaining window (popup windows) ID take using method driver.getwindowhandles();
Now use the FOR LOOP and check the presence of your element in popup window one by one.
2.2) if there is single popup then means alert box then you can your
driver.alert() method