0

I have to bring to front a Chrome tab (already open) with code.

More precisely, I have a tab (with its url) open in a Chrome browser (in kiosk mode) and, when the tab is in background, I want to bring it to front by means of a Chrome shortcut, an execuble file or a script.

The tab brought to front must be the same that was in background, and with the same url.

Can I do this with Python or by means of a Chrome shortcut, configuring its properties?

nicc96
  • 313
  • 2
  • 16
  • you may be able to iterate through the tabs that are not the ones you want open and close them instead, https://stackoverflow.com/questions/29502255/is-there-a-way-to-close-a-tab-in-webdriver-or-protractor if you open it via webdriver in the first place – Paul Collingwood Apr 20 '22 at 21:58
  • do you use [Selenium](https://selenium-python.readthedocs.io/) to control web browser? – furas Apr 20 '22 at 23:00

1 Answers1

0
#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)
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
  • This code opens a tab in Chrome but, if I execute it 2 times, it opens 2 tabs. I need a code that open the url always in the same tab – nicc96 Apr 20 '22 at 21:03
  • Welcome to Stack Overflow. Code is a lot more helpful when it is accompanied by an explanation. Stack Overflow is about learning, not providing snippets to blindly copy and paste. Please [edit] your question and explain how it answers the specific question being asked. See [answer]. – ChrisGPT was on strike Apr 20 '22 at 21:46