2

I have tried each of these solutions to no avail in attempt to achieve the same thing that was discussed on this thread. Yet that console window sticks around.

#kill console through .system
import os, sys
#webbrowsing modules
from selenium import webdriver

#function to launch browser in chrome
def launch_chrome(page):
    browser = webdriver.Chrome(r'C:\Users\cj9250\AppData\Local\Continuum\anaconda3\chromedriver.exe')
    browser.get(page)
    return browser

url = "https://www.google.com/"

browser = launch_chrome(url)

#prints 'SUCCESS: The process "chromedriver.exe" with PID 9872 has been terminated.'
#in the terminal and leaves it open
os.system('taskkill /F /im chromedriver.exe')

quit()
#never gets to this print command
print('it quit')

#closes the browser as well
browser.service.stop()

sys.exit
print('it exit')

I should note that I am running my programs from batch files called by win+r similar to the way described in Automate the Boring Stuff. I also am running Python through Anaconda.

Jack
  • 89
  • 8
  • have you tried taskkil python.exe? – johnashu May 01 '18 at 20:49
  • Why are you trying to call **quit()** after forcefully killing **chromedriver.exe**? What is your _usecase_ exactly? – undetected Selenium May 02 '18 at 09:31
  • I should note that I have tried each of the three solutions on the bottom individually, commenting the others out. By usecase are you asking more details on what I'm trying to do exactly? I will attempt taskkill python.exe and report back. – Jack May 02 '18 at 15:23
  • Killing python produces a similar result to chromedriver, the console stays open and reports that python has been successfully killed. – Jack May 02 '18 at 15:27

0 Answers0