0

#profile
chrome_options.add_argument(r"user-data-dir=C:\Users\prodi\AppData\Local\Google\Chrome\User Data\Profile 2") 
#Path to your chrome profile

service = ChromeService(executable_path=r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe')

driver = webdriver.Chrome(service=service,options=chrome_options)

driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")

#get url
tempUrl = "https://www.indeed.com/jobs?q=Web+Dev+Intern&l=Remote&sc=0kf%3Aattr%28DSQF7%29explvl%28ENTRY_LEVEL%29%3B&rbl=Remote&jlid=aaa2b906602aa8f5&pp=gQAAAAABhyaEcDMAAAAB_d4VZAADAAABAAA&vjk=e8d531753a776d38"

driver.get(tempUrl)

pickle.dump(driver.get_cookies(), open("cookies.pkl", "wb"))


Hello I am trying to go to a url with my google profile. It isnt working. The chrome profile pops up but it dosent do anything. After a while it just gives me a cant connect error.

this:

Traceback (most recent call last):
  File "c:\Users\prodi\Desktop\auto job applying bot\auto-job-applying-bot\Test Code\main.py", line 52, in <module>
    driver = webdriver.Chrome(service=service,options=chrome_options)
  File "C:\Users\prodi\Desktop\auto job applying bot\auto-job-applying-bot\env\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 80, in __init__    
    super().__init__(
  File "C:\Users\prodi\Desktop\auto job applying bot\auto-job-applying-bot\env\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 101, in __init__ 
    self.service.start()
  File "C:\Users\prodi\Desktop\auto job applying bot\auto-job-applying-bot\env\lib\site-packages\selenium\webdriver\common\service.py", line 113, in start        
    raise WebDriverException(f"Can not connect to the Service {self.path}")      
selenium.common.exceptions.WebDriverException: Message: Can not connect to the Service C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

I tried many solutions

first is to make sure paths are right. They are looking https://i.stack.imgur.com/hO50z.jpg

second this: one solution says to use a cookie. did nothing Selenium: get() not working with custom google profile

the others also do noting what is wrong?

1 Answers1

1

The issue seems to be stemming from this line:

service = ChromeService(executable_path=r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe')
driver = webdriver.Chrome(service=service,options=chrome_options)

Because you are creating a ChromeService instance with the Chrome browser executable, even though you should be using the Chromedriver executable. See relevant docs.
A fix for this that I would recommend you to do, since it's a pain to always manually upgrade your Chromedriver version whenever your Chrome Browser updates would be to use the webdriver-manager package. The code would then look like this:

from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)
Romek
  • 284
  • 2
  • 10