Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Finding an issue in ending the python process

I have a script to run a webdriver in a headless mode. I’m observing that after the whole execution of the script, the process is still running.

Here’s the imitation of the issue I’m facing.

from selenium import webdriver
from webbrowser import Chrome
from ssl import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options


class PythonOrg():

    def Setup(self):
        self.chrome_options = Options()
        self.chrome_options.add_argument("--headless")
        # self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) #not a headless
        self.driver = webdriver.Chrome(options=self.chrome_options)

    
    def GetLink(self):
        driver = self.driver
        driver.get('https://www.python.org')
        print(driver.title)
        driver.close()
        print('Closed the driver')


inst = PythonOrg()


inst.Setup()
inst.GetLink()

Note: This is just a replication of the issue from the actual project.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Help me understand how can I manage the process when it gets completed, I’m new to Python platform.

>Solution :

There is two options for webdriver – quit() and close()

# Closes the current window
driver.close()

# All windows related to driver instance will quit
driver.quit()

Seems you are just closing the window, thus why the instance is still active.
Use quit() to terminate the instance.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading