Home > Software design >  Selenium can't open chrome
Selenium can't open chrome

Time:12-20

I was trying to open the CoinGecko website in a different profile in Chrome, but when I ran the code, it didn't throw any errors and just ended without opening the browser. I was wondering if you could help me figure out what I might be missing?

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager


options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument(
    r"--user-data-dir=<directory path here>"
)  # e.g. C:\Users\You\AppData\Local\Google\Chrome\User Data
options.add_argument(r"--profile-directory=<Profile number here>")  # e.g. Profile 3
driver = webdriver.Chrome(
    service=Service(ChromeDriverManager().install()), options=options
)

# Set the URL of the website you want to open
url = "https://www.coingecko.com/"

# Open the website
driver.get(url)

CodePudding user response:

Remove the line - options.add_argument("--headless"), this line will open the browser in headless mode, and the browse window will not be visible.

  • Related