This is very common scenario when we automate any web application. But I am little confused between new window and pop-up?
Please can you add little examples?
Since you have asked for examples, here it is e.g. visit appium tutorial webpage. Click on any chapter say chapter 1. It will take you to new window/tab.
for alert, think of any website which pops up message as "Do you want to continue", "Click on OK to continue", "Are you sure want to Cancel" etc
Click on try it.