pythonseleniumselenium-webdriverwindow-handlesgetcurrenturl

Selenium: How to get current url of a tab without switching to it?


I often open hundreds of tabs when using web browsers, and this slows my computer. So I want to write a browser manager in Python and Selenium , which opens tabs and can save the urls of those tabs, then I can reopen them later.

But it seems like the only way to get the url of a tab in Python Selenium is calling get_current_url.

I'm wondering if there's a way to get the url of a tab without switching to it?


Solution

  • There is no other way to get the specific tab titles of the browser without switching to the specific TAB as Selenium needs focus on the DOM Tree to perform any operation.