CHROMEDRIVER_OPTIONS Syntax

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
gtdalsanto
Pro Scripter
Posts: 51
Joined: Tue Oct 03, 2006 4:22 pm
Location: Akron, Ohio
Contact:

CHROMEDRIVER_OPTIONS Syntax

Post by gtdalsanto » Wed Sep 01, 2021 3:01 pm

Does anyone have a list of options that can be used and the correct syntax when setting CHROMEDRIVER_OPTIONS variables? From the available examples, setting it up to maximize the screen (--start-maximized) works fine. But I am trying to use other possible chrome options (which might not be supported by Macro Scheduler) and I am getting the following line error:

Line xx - (1:1) Unquoted string in JSON data only valid for dictionary names.

The option I am trying to set is "user-data-dir" option with the following lines:

Let>CHROMEDRIVER_EXE=%SCRIPT_DIR%\ChromeDriver\chromedriver.exe
Let>CHROMEDRIVER_OPTIONS=--user-data-dir="C:\Users\id1"
ChromeStart>session_id

Is my syntax wrong or are the commands allowed by this variable limited. I have tried different variations with the quotes and nothing seems to work here.

Thanks

Gary
Gary T. DalSanto
Inventive Software Designs, LLC
[email protected]

User avatar
Grovkillen
Automation Wizard
Posts: 1131
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: CHROMEDRIVER_OPTIONS Syntax

Post by Grovkillen » Wed Sep 01, 2021 3:26 pm

I haven't been able to set the download path. I've since come to use the default download path and just copy the files from there to wherever I want.
Let>ME=%Script%

Running: 15.0.27
version history

NickD
Pro Scripter
Posts: 58
Joined: Fri Sep 23, 2016 2:17 pm

Re: CHROMEDRIVER_OPTIONS Syntax

Post by NickD » Tue Apr 19, 2022 4:14 am

Actually,

Code: Select all

user-data-dir=
is a startup switch that tells chrome to open a specific user profile rather than the default blank profile.

I spoke to Marcus about this switch back in October 2020 and was told:
I think you mean CHROMEDRIVER_OPTIONS which is just for startup switches. So you could do:
Let>CHROMEDRIVER_OPTIONS=--user-data-dir=/path/to/existing/profile
Having tried this myself, I cannot get this startup switch to work.

@Marcus_Tettmar are we configuring this switch incorrectly or is it broken? If it works, could you share an example of how to configure the flag and file path?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: CHROMEDRIVER_OPTIONS Syntax

Post by Dorian (MJT support) » Tue Apr 19, 2022 10:07 am

The solution seems to be rather convoluted.

Source : this post

The important part here is : "Chromedriver automatically adds "Default" to the end of "user-data-dir=."

So I followed the instructions from "2nd case" and adapted them for Macro Scheduler:
2nd case: you're using another chrome profile (noted by Profile 1, Profile 2, etc. in chrome://version)

Navigate to that profile path. Should be something like C:\Users\david\AppData\Local\Google\Chrome\User Data\Profile 1.

Copy and paste that entire folder into whatever place you would like.(ex: D:\Chrome_Profiles). Your directory would look something like this: D:\Chrome_Profiles\Profile 1

Change Profile 1 to Default. Your directory will look something like this: D:\Chrome_Profiles\Default

Chromedriver automatically adds "Default" to the end of the options.add_argument(r"user-data-dir= part. Thus, you would just use:

options.add_argument(r"user-data-dir=D:\Chrome_Profiles") driver.get("https://www.facebook.com")
My Steps :
1. Created C:\Chrome_Profiles
2. Navigated to C:\Users\username\AppData\Local\Google\Chrome\User Data\Profile 1. (EDIT: Note that "Profile 1" may instead be "Default")
3. Copied Profile 1 folder to C:\Chrome_Profiles
4. Renamed "Profile 1" to "Default" - thus C:\Chrome_Profiles\Default (EDIT: If the folder in step 2 was already named "Default" no renaming is required).

Seeing as ChromeDriver adds "Default" we can now just use this :

Code: Select all

Let>CHROMEDRIVER_OPTIONS=--user-data-dir=/Chrome_Profiles
Thus : (tested and working)

Code: Select all

Let>TheURL=chrome://version/
Let>CHROMEDRIVER_EXE=c:\chromedriver.exe
Let>CHROMEDRIVER_OPTIONS=--user-data-dir=/Chrome_Profiles

KillProcess>chromedriver.exe
ChromeStart>session_id
ChromeNavigate>session_id,url,%TheURL%
Yes, we have a Custom Scripting Service. Message me or go here

NickD
Pro Scripter
Posts: 58
Joined: Fri Sep 23, 2016 2:17 pm

Re: CHROMEDRIVER_OPTIONS Syntax

Post by NickD » Sat May 21, 2022 6:50 pm

Thanks Dorian,

It's great to finally be able to use a defined and persistent chrome profile!
I tried something very similar a while back, but got an error relating to unquoted JSON strings that I was unable to resolve, in reflection it obviously relates to the file path, rather than being an issue with the flag itself. Is there a limitation that restricts the flag to C:\ drive? (My documents are on D:\, which means so is my %BMP_DIR% filepath)

Code: Select all

Let>chrome_user_profile={"C:\Users\nickd\AppData\Local\Google\Chrome\User Data\Default"}

IfNotFileExists>%BMP_DIR%\Chrome_Profile
CopyFolder>%chrome_user_profile%,%BMP_DIR%\Chrome_Profile
Endif

Let>CHROMEDRIVER_OPTIONS=--user-data-dir=%BMP_DIR%\Chrome_Profile

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: CHROMEDRIVER_OPTIONS Syntax

Post by Dorian (MJT support) » Mon May 23, 2022 10:21 am

There doesn't seem to be a limitation regarding location.

I used your script to copy over my Chrome Profile folder and was able to use this :

Code: Select all

Let>CHROMEDRIVER_OPTIONS=--user-data-dir=d:/Chrome_Profile
Note that you have \ instead of /.

I'm not sure why you're using your bmp_dir to store your Chrome Profile. Surely this folder may not always exist, as it's a subfolder created by the Image Recognition Wizard.

Are you attempting to set your download folder?

If so, once you have Let>CHROMEDRIVER_OPTIONS=--user-data-dir=wherever working, you could simply start up a session and then in >Settings >Advanced >Downloads change the download location. Then whenever you start an automated Chrome session using that profile it will be remembered.
Yes, we have a Custom Scripting Service. Message me or go here

pgriffinX
Newbie
Posts: 2
Joined: Tue Jun 11, 2024 10:33 pm

Re: CHROMEDRIVER_OPTIONS Syntax

Post by pgriffinX » Tue Jun 11, 2024 10:40 pm

I am trying to use this setting. In your Let>ChromeDriver_OPTIONS line, you use / instead of a typical file path which uses \
my default folder is in a c:\folder\chromefiles\chromeProfile\default location.
how do I specify this if not with a typical file path?
thanks

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: CHROMEDRIVER_OPTIONS Syntax

Post by Dorian (MJT support) » Wed Jun 12, 2024 1:46 pm

I copied my files to c:\folder\chromefiles\chromeProfile\default to test and used the following. Tested and working :

Code: Select all

Let>CHROMEDRIVER_OPTIONS=--user-data-dir=/folder/chromefiles/chromeProfile/default
OR

Code: Select all

Let>CHROMEDRIVER_OPTIONS=--user-data-dir=/folder/chromefiles/chromeProfile/default,--start-maximized
Inside c:\folder\chromefiles\chromeProfile\default you should have files/folders copied as per my instructions in this thread. The first few folders would be AutofillRegex, AutofillStates, BrowserMetrics.. etc etc.
Yes, we have a Custom Scripting Service. Message me or go here

pgriffinX
Newbie
Posts: 2
Joined: Tue Jun 11, 2024 10:33 pm

Re: CHROMEDRIVER_OPTIONS Syntax

Post by pgriffinX » Thu Jun 20, 2024 3:35 am

I have moved the default folder to the desired location and pointing to it with the user data dir setting.
The Chrome session starts, MSched gets the spinning wheel and when the wheel stops, the session crashes.
No error pops up and there is not chrome session in the task manager.
suggestions?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts