Python script to load URL in an existing Chrome tab

By the way, when executing the program with a certain browser, all browsers remain open regardless of assigning a new browser to the same variable. However, this method makes it impossible to access the previous browsers. If opening tabs is required, one may either use the specified method or utilize JavaScript. To switch between tabs, obtain the handler to the current tab, and then use it to switch to said tab. For multiple tabs, it is recommended to maintain a list.


Question:

I need to use code to bring a
Chrome tab
that is already open to the front.

To clarify, I currently have a Chrome browser open in kiosk mode with a specific tab and its corresponding URL. My goal is to bring the tab to the forefront using either an executable file, a script, or a
Chrome shortcut
.

The tab that is brought to the foreground should have the identical URL as the one that was previously in the background.

Is it possible to achieve this task using Python or by configuring the properties of a Chrome shortcut?


Solution:

#Open google in python - Windows.
import webbrowser
url='https://google.com'
webbrowser.get('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s').open(url)

Frequently Asked Questions