10

Is it possible to connect selenium to the browser I use normally instead a driver? For normal browsing I am using chrome with several plugins - add block plus, flashblock and several more. I want to try to load a site using this specific configuration. How can I do that?

p.s - I dont want to connect only to an open browser like in this question :

How to connect to an already open browser?

I dont care if I spawn the process using a driver. I just want the full browser configuration - cookies,plugins,fonts etc.

Thanks

Community
  • 1
  • 1
WeaselFox
  • 6,770
  • 6
  • 39
  • 72

1 Answers1

11

First, you need to download the ChromeDriver, then either put the path to the executeable to the PATH environment variable, or pass the path in the executable_path argument:

from selenium import webdriver
driver = webdriver.Chrome(executable_path='/path/to/executeable/chrome/driver')

In order to load extensions, you would need to set ChromeOptions:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = webdriver.ChromeOptions()
options.add_extension('Adblock-Plus_v1.4.1.crx')

driver = webdriver.Chrome(chrome_options=options)

You can also save the chrome user profile you have and load it to the ChromeDriver:

options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir=/path/to/my/profile')
driver = webdriver.Chrome(chrome_options=options)

See also:

Community
  • 1
  • 1
alecxe
  • 414,977
  • 106
  • 935
  • 1,083
  • Thanks for your answer. How about fonts? I would like to use the same fonts installed on my chrome for browsing in my webdriver. Can that be done? – WeaselFox Jul 29 '14 at 14:54
  • @WeaselFox I'd try to save/load the user profile. I've updated the answer, hope it helps. – alecxe Jul 29 '14 at 15:00