Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I use selenium with my normal browser

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

like image 378
WeaselFox Avatar asked Jul 29 '14 14:07

WeaselFox


Video Answer


1 Answers

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:

  • Running Selenium WebDriver using Python with extensions (.crx files)
  • ChromeDriver capabilities/options
like image 171
alecxe Avatar answered Oct 08 '22 21:10

alecxe