Reputation: 351
I am facing an issue with chrome while launching it with extensions using selenium. I have logged an issue https://code.google.com/p/chromedriver/issues/detail?id=508
For a workaround I am planing to launch chrome than enable required extension, after this connect to it using selenium.
But I am unable to so so. Can anyone help in this matter as d=webdriver.Chrome() always launches a new chrome instance. I want to connect to an already running instance of chrome.
Upvotes: 5
Views: 12929
Reputation: 13743
You can, it's covered here
So e.g.
If you do
(adjust the command for your needs, your chrone path.. and the user profile you want to use). chrome://version can show you the chrome user profile folder for whatever chrome user.
C:\Users\User>"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=8989 --user-data-dir="C:\Users\User\App
Data\Local\Google\Chrome\User Data\Profile 3"
C:\Users\User>
Then in your python program
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
opt = Options()
opt.add_experimental_option("debuggerAddress", "localhost:8989")
selclient = webdriver.Chrome(options=opt)
selclient.get("http://www.dogpile.com")
That python code will not launch a new chrome window. It will connect to the already existing chrome instance that you started from eg the command line.
Upvotes: 0
Reputation: 2932
**Reconnect to a driver in python selenium **
This is applicable on all drivers.
1. open a driver
driver = webdriver.Firefox()
extract to session_id and _url from driver object.
url = driver.command_executor._url #"http://127.0.0.1:60622/hub"
session_id = driver.session_id #'4e167f26-dc1d-4f51-a207-f761eaf73c31'
3.Use these two parameter to connect to your driver.
driver = webdriver.Remote(command_executor=url,desired_capabilities={})
driver.session_id = session_id
And you are connected to your driver again.
driver.get("http://www.mrsmart.in")
Upvotes: 8
Reputation: 174
Now it is,
reference: github issue
Upvotes: 3
Reputation: 25056
This is simply not possible in Selenium, in any browser and in any programming language.
https://code.google.com/p/selenium/issues/detail?id=18
Upvotes: 6