Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for profile-directory command line option #963

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,17 @@ func UserDataDir(dir string) ExecAllocatorOption {
return Flag("user-data-dir", dir)
}

// UserDataProfileDir is the command line option to set the profile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • UserDataProfileDir --> ProfileDirectory
  • the profile subdirectory under the UserData directory --> the profile directory under the user data directory

// subdirectory under the UserData directory.
//
// Note: if unspecificed Chrome will choose/create the folder "Default".
// This folder contains the profile specific data like cookies & cache.
// If multiple profile exists they are typically named "Profile 1",
// "Profile 2", etc.
func UserDataProfile(profile string) ExecAllocatorOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ProfileDirectory is better.

Copy link
Author

@zvodd zvodd Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was a little bit concerned about the ambiguity there. Because the word "directory" might imply that you need to specify a full path.
I think that this is a actually a rare enough use case as well as being potentially confusing enough, to cancel this pull request.

If someone needs the feature they can always just use chromedp.Flag:

opts := []chromedp.ExecAllocatorOption{
	chromedp.UserDataDir("/home/user/.config/google-chrome"),
	chromedp.Flag("profile-directory", "Profile 2"),
}
ctx, cancel := chromedp.NewExecAllocator(context.Background(), opts...)
defer cancel()
ctx, cancel = chromedp.NewContext(ctx)
defer cancel()

I think maybe providing an example in /examples might be a better alternative.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is a actually a rare enough use case as well as being potentially confusing enough, to cancel this pull request.

Yes, I can not think of a use case for this option.

return Flag("profile-directory", profile)
}

// ProxyServer is the command line option to set the outbound proxy server.
func ProxyServer(proxy string) ExecAllocatorOption {
return Flag("proxy-server", proxy)
Expand Down