Selenium Phyton Chrome open with def options
<p>I want open Google Chrome, like its self, the chromedriver open it without my cookies, my passwords, my history and all that staff.
i tried to play with the option, and search all over the web for solution,
didn't got one,
plus i tried</p>

<p>from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options</p>

<pre><code>opt = webdriver.ChromeOptions()
opt.add_arguments("--user-data-dir=C:\Users\Bar\AppData\Local\Google\Chrome\User Data")
driver = webdriver.Chrome(opt)
driver.get("https://www.google.com/")
</code></pre>

<p>but it didn't work it says:</p>

<pre><code>C:\Users\Bar\AppData\Local\Programs\Python\Python35-32\python.exe C:/Users/Bar/PycharmProjects/yad2/Webdriver.py
  File "C:/Users/Bar/PycharmProjects/yad2/Webdriver.py", line 7
    opt.add_arguments("--user-data-dir=C:\Users\Bar\AppData\Local\Google\Chrome\User Data")
                     ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 18-19: truncated \UXXXXXXXX escape

Process finished with exit code 1
</code></pre>

<blockquote>
  <p>AttributeError: 'Options' object has no attribute 'add_arguments'</p>
</blockquote>

<p>It should be <code>add_argument</code> instead of <code>add_arguments</code>. You should try as :-</p>

<pre><code>from selenium import webdriver
from selenium.webdriver.chrome.options import Options

opt = webdriver.ChromeOptions() 
opt.add_argument("user-data-dir=C:\Users\Bar\AppData\Local\Google\Chrome\User Data")
</code></pre>

<blockquote>
  <p>AttributeError: 'Service' object has no attribute 'process'</p>
</blockquote>

<p>Now you need to set this <code>opt</code> into <code>chrome_options</code> and pass it into <code>ChromeDriver</code> as :-</p>

<pre><code>driver = webdriver.Chrome(chrome_options=opt)
driver.get("https://www.google.com/")
</code></pre>

<p><strong>Edited</strong> :- You need to <a href="http://chromedriver.storage.googleapis.com/index.html?path=2.23/" rel="nofollow">download latest <code>chromedriver.exe</code></a> executable from here and extract this zip into at any location of your system and provide this path location with executable <code>chromedriver.exe</code> as <code>executable_path="path/to/chromedriver.exe"</code> and Initialize <code>ChromeDriver</code> as :-</p>

<pre><code>driver = webdriver.Chrome(executable_path="path/to/chromedriver.exe", chrome_options=opt)
driver.get("https://www.google.com/")
</code></pre>

python selenium selenium-webdriver