How to interact with popup Browser using Selenium and Python

Viewed 138

I am trying to switch to the browser popup window using python and selenium, the javascript code of the website I am trying to automate is like this:

<script>
// JavaScript popup window function
    function basicPopup(url) {
popupWindow = window.open(url,'popUpWindow','height=300,width=700,left=50,top=50,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes')
    }

</script>
<a href="https://example.com" onclick="basicPopup(this.href);return false">Open a popup window</a>

It opens https://example.com on the new browser popup window.

Now, I am trying to interact with that popup browser using Selenium and python, but I do not know how. I can only switch through tabs like this:

driver.switch_to.window(driver.window_handles[1])

But it did not work as it can only switch to other "popup tabs" and not "popup browser"

0 Answers
Related