ChromeDriver options not working

98 views
Skip to first unread message

Iron Bars

unread,
Jun 9, 2024, 11:28:10 PMJun 9
to Selenium Users
I am trying to create a python script utilizing ChromeDriver which opens a new message in gmail and then autofills the to and subject fields. However I am having problem without even getting to the last part. I tried to follow the latest options information on selenium page but even though the options to me look like they match it does not work. The options are not applied on the opening page at all. I want it to be maximized and to use my user data so I don't need to login but it just does not. My chrome is 125.0.6422.142 and so is my ChromeDriver. My selenium is 4.21.0 and my python is 3.12
from selenium import webdriver

def open_chrome():
    options = webdriver.ChromeOptions()
    options.add_argument("--start-maximized")
    options.add_argument("--user-data-dir=Current user data dir")

    driver = webdriver.Chrome(options=options)

open_chrome()

Sir Jo

unread,
Jun 11, 2024, 6:32:04 AMJun 11
to Selenium Users

if your user-data-dir path contains space (as I see) maybe you need to add quotation mark, so try with

options.add_argument("--user-data-dir=\"Current user data dir\"")

Iron Bars

unread,
Jun 11, 2024, 12:24:45 PMJun 11
to Selenium Users
That is not my actual user data path, the correct one has backslashes and no spaces, but the maximized option should still work

Sir Jo

unread,
Jun 11, 2024, 5:13:26 PMJun 11
to Selenium Users

when you use --user-data-dir argument you need also use --profile-directory argument

p.s.: errata corrige: if path contains space no need to use quotation marks
Reply all
Reply to author
Forward
0 new messages