Skip to content

Do you can concurently launch several chrome instances each with own user-data-dir #429

Answered by ysmood
MikhailKlemin asked this question in Q&A
Discussion options

You must be logged in to vote
func create(profile string) *rod.Browser {
	u := launcher.New().UserDataDir(profile).
		Set("blink-settings", "imagesEnabled=false").
		MustLaunch()

	return rod.New().ControlURL(u).MustConnect()
}

func main() {
	wg := sync.WaitGroup{}
	for range "....." {
		wg.Add(1)
		go func() {
			defer wg.Done()

			p := filepath.Join(os.TempDir(), utils.RandString(8))

			b := create(p)
			b.MustPage()
			fmt.Println("Browser started:", p)
			time.Sleep(5 * time.Second)
			b.MustClose()
			fmt.Println("Browser stopped:", p)
		}()
	}
	wg.Wait()
}

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
5 replies
@MikhailKlemin
Comment options

@ysmood
Comment options

@MikhailKlemin
Comment options

@ysmood
Comment options

@MikhailKlemin
Comment options

Comment options

You must be logged in to vote
1 reply
@MikhailKlemin
Comment options

Answer selected by MikhailKlemin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants