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: 1009
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.24
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: 1348
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 :
Created C:\Chrome_Profiles
Navigated to C:\Users\username\AppData\Local\Google\Chrome\User Data\Profile 1.
Copied Profile 1 folder to C:\Chrome_Profiles
Renamed "Profile 1" to "Default" - thus C:\Chrome_Profiles\Default

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: 1348
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

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