Chrome browser ends when I run the code on python selenium.

113 views
Skip to first unread message

BJ

unread,
Oct 12, 2023, 10:58:39 PM10/12/23
to Selenium Users
import os

from selenium import webdriver

os.environ['PATH'] += r"C:/ChromeDriver"

driver=webdriver.Chrome()

When I run the code, the chrome open and then close in seconds.

In terminal it shows the output as:


Plz, help me. I'm new to selenium.

Note: I installed the chromedriver according to my chrome version.

Michael James

unread,
Nov 30, 2023, 2:47:52 AM11/30/23
to Selenium Users
To keep the Chrome browser open, it is advisable to incorporate Chrome options into the existing program, as demonstrated below :

from selenium import
webdriver options = webdriver.ChromeOptions() 
options.add_experimental_option("detach", True)
 driver = webdriver.Chrome(options=options) 
driver.get("https://www.python.org")  

I am available to assist further and ensure a seamless resolution of this issue.
Reply all
Reply to author
Forward
0 new messages