I am using 3rd party software to create a fancy application GUI with several buttons.
Each buttons will execute different .py file/.exe file. For instance:-
btnYahoo = execute yahoo.py/yahoo.exe
btnGoogle = execute google.py/google.exe
So inside both py scripts is using chromedriver to launch Chrome Browser and redirect to specific URLs
google.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path=r'chromedriver.exe')
driver.get("https://www.google.com")
yahoo.py
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path=r'chromedriver.exe')
driver.get("https://malaysia.yahoo.com/?p=us")
So if I execute both scripts above, it will launch 2 chrome browser.
Therefore, my concern is how can I check is webdriver.Chrome is running?
If so, then assign the webdriver.Chrome to a variable, so that I can open new tab and do further automate script progress.
For example of expected result:
Execute google.py - A new chrome browser is open and redirect to www.google.com
Execute yahoo.py - If webdriver.Chrome is executed/existed, then assign the browser to driver variable. Else launch new browser
Thanks for advance information.
driver.quit()
. If you do not use quit() at the end of program, the WebDriver session will not be closed properly and the files will not be cleared off memory. This may result in memory leak errors. This could be looked up in the task manager: it will have chromedriver.exe remaining from previous runs. This happens in the JavaScript version of the selenium-webdriver client and might also be the case for Python. – Stupendous