Is it possible to automatically focus to the pop-up (be it a modal window or a dialog box) after clicking a link.
I found something like this from How can selenium web driver get to know when the new window has opened and then resume its execution
driver.find_element_by_id("id of the button that opens new window").click()
WebDriverWait(driver, timeout=50).until(found_window("new window name"))
WebDriverWait(driver, timeout=10).until( # wait until the button is available
lambda x: x.find_element_by_id("id of button present on newly opened window"))\
.click()
But even here we need to know the id or any attribute of the pop-up. Is there some way we can run an automated script in Selenium so that it catches any pop-up window and auto-focus to that and returns back to the parent window only once the tests are performed on the pop-up.
Thanks in advance!
P.S. I use Selenium-Python