I am trying to open a website on chrome via selenium with the following code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s=Service('C:/Users/Morteza/Documents/Dev/chromedriver.exe')
browser = webdriver.Chrome(service=s)
url='https://www.google.com'
browser.get(url)
link to problem: https://share.cleanshot.com/p1qu5y
CodePudding user response:
This is not an issue or crash. After the specified actions are completed successfully, selenium closes the web browser. This program works fine.
Use the following code with a while True block
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
CodePudding user response:
This isn't any crash or an error as such. Selenium automatically closes the client i.e. the Chrome Browser instance after executing the last line of your code. However this practice may accumulate undeleted/zombie chromedriver instances within your system.
Ideally, you always need to invoke driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully at the end of your tests.
CodePudding user response:
the chromedrive path in your code, i guess your platform is windows
.
but the picture you post revease that your machine is mac
.
pay attention to the chromedriver file PATH
and your PC platform
, make sure they suit to each other.
or you could put chromedriver in system PATH variable
, so you do not need to specify the chromedrive path in your code