0

I'm new to Selenieum and still trying to understand how the different pieces work together. I am trying to automate some interaction tasks on an internal website using Python. However, I am trying to use the existing Chrome browser session AFTER I've authenticated with my username and password rather than launching a new browser. I'd like to start where my browser is currently and I'd also like to use a separate profile when launching chrome as to not pollute the default Chrome browser (not sure this is necessary). The driver is currently on a folder on my desktop and I also created a variable ChromeDriver location in my PATH environment variable on my Mac but I am not sure that is really necessary. I also created I've researched several similar post and found the code below on SO, but when I run it still opens a new browser and drops me at the login screen.

from selenium import webdriver

PATH = 'where chrome driver is located'
driver = webdriver.Chrome(PATH)

url = driver.command_executor._url
session_id = driver.session_id

driver = webdriver.Remote(command_executor=url,desired_capabilities={})
driver.close() 
driver.session_id = session_id

driver.get("https://whereidliketobeafterlogin")
bbal20
  • 113
  • 4
  • 11

1 Answers1

-1

Based on this post here it looks like your answer may already be available.

I had a similar requirement but it was part of a larger application so i created a quick dialog box using the built in tkinter library to take a username and password so that Selenium could do the log in for me, that way my user data was never stored anywhere.

As far as using a separate profile than whats currently logged in your browser and all, when Selenium web driver starts up a new browser it functions as if it is in the incognito/private version, not retaining any of the login/session info unless specified through parameters.

Lastly, the PATH environment variable isnt entirely necessary, as long as you give filepath to the driver on your desktop when you create your webdriver object you are good.

BrianK271
  • 34
  • 2