Skip to content Skip to sidebar Skip to footer

How Can I Open A New Browser Tab With Subprocess?

I'm opening a new IE window with this: subprocess.Popen(r''' + os.environ['PROGRAMFILES'] + '\Internet Explorer\IEXPLORE.EXE' ' + Call_URL) This is fine when IE is closed, but e

Solution 1:

Since you also wanted a standard browser am giving an example to open a new tab with chrome. If chrome is not open already it will open and then navigate to the URL.

import subprocess
subprocess.Popen("start chrome /new-tab www.google.com",shell = True)

This works. Please try and let me know if this is what you wanted.

Another one without hardcoding the Call_URL

import subprocess
Call_URL = "www.google.com"
mycmd = r'start chrome /new-tab {}'.format(Call_URL)
subprocess.Popen(mycmd,shell = True) 

Are you expecting something like this?


Post a Comment for "How Can I Open A New Browser Tab With Subprocess?"