CHROMEDRIVER_OPTIONS Syntax
Moderators: Dorian (MJT support), JRL
-
- Pro Scripter
- Posts: 51
- Joined: Tue Oct 03, 2006 4:22 pm
- Location: Akron, Ohio
- Contact:
CHROMEDRIVER_OPTIONS Syntax
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
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
- Grovkillen
- Automation Wizard
- Posts: 1131
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: CHROMEDRIVER_OPTIONS Syntax
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.
Re: CHROMEDRIVER_OPTIONS Syntax
Actually, 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:
@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?
Code: Select all
user-data-dir=
I spoke to Marcus about this switch back in October 2020 and was told:
Having tried this myself, I cannot get this startup switch to work.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
@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?
- Dorian (MJT support)
- Automation Wizard
- Posts: 1390
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: CHROMEDRIVER_OPTIONS Syntax
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:
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 :
Thus : (tested and working)
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:
My Steps :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")
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
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
Re: CHROMEDRIVER_OPTIONS Syntax
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)
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
- Dorian (MJT support)
- Automation Wizard
- Posts: 1390
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: CHROMEDRIVER_OPTIONS Syntax
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 :
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.
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
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
Re: CHROMEDRIVER_OPTIONS Syntax
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
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
- Dorian (MJT support)
- Automation Wizard
- Posts: 1390
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: CHROMEDRIVER_OPTIONS Syntax
I copied my files to c:\folder\chromefiles\chromeProfile\default to test and used the following. Tested and working :
OR
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.
Code: Select all
Let>CHROMEDRIVER_OPTIONS=--user-data-dir=/folder/chromefiles/chromeProfile/default
Code: Select all
Let>CHROMEDRIVER_OPTIONS=--user-data-dir=/folder/chromefiles/chromeProfile/default,--start-maximized
Yes, we have a Custom Scripting Service. Message me or go here
Re: CHROMEDRIVER_OPTIONS Syntax
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?
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?