2

I have a python application using selenium to basically just start up a chrome instance with a preloaded profile. It all works perfectly fine, besides that I always get this error message in the terminal: "selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir"

So on to my question: How do I specify a unique value for --user-data-dir?

I have tried to look it up online but only happened to find proper solutions for selenium with java but unfortunately not for python

Here is part of my code so far:

from selenium import webdriver

class WhatsApp():
    def __init__(self,time):
        self.time = time
        self.chrome_options = webdriver.ChromeOptions()
        self.chrome_options.add_argument("user-data-dir=C:\\Users\\43678\\AppData\\Local\\Google\\Chrome\\User Data")
        self.driver = webdriver.Chrome(options=self.chrome_options)
Leo
  • 45
  • 1
  • 5
  • I think you'll just need to set this to any directory that isn't already associated with a profile. If you don't need a specific directory, just don't set it. The directory will be created. – pcalkins Aug 16 '19 at 21:16

0 Answers0