Reputation: 13
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import datetime
ch_options = webdriver.ChromeOptions()
ch_options.add_argument("--user-data-dir=C:\\Users\\Dossy\\AppData\\Local\\Google\\Chrome\\User Data")
chrome = webdriver.Chrome(options=ch_options)
chrome.get("https://www.google.com/")
this code only open up the chromedriver with my profile, but couldn't redirect to a link
Upvotes: 1
Views: 1603
Reputation: 59
If you have problem in first solution and try this:
First copy the of chrome driver path:
Then,go to the "This PC" and right click on it and then go to the properties:
After it go to the advanced system setting:
Then, click on Environment Variable
Then,In system variable click on Path and then click on edit:
After it,paste the copied path with \chromedriver.exe then click on "Ok":
and click "Ok" on all the tabs That's it Now try it Comment if you are having still problem in this.
Upvotes: 0
Reputation: 59
Instead of writing this:
ch_options = webdriver.ChromeOptions()
ch_options.add_argument("--user-data-dir=C:\\Users\\Dossy\\AppData\\Local\\Google\\Chrome\\User Data")
you can directly give the path
ch_options = webdriver.Chrome('**HERE GIVE YOUR FULL PATH OF chromedriver.exe**')
like:
chrome = webdriver.Chrome('C:\\Users\\Lucky\\Downloads\\.zip\\chromedriver.exe')
Your browser will open and it and will also redirect you to the link.
Upvotes: 1
Reputation: 7
Making it so simple and short: Make sure to add the chrome driver path correctly
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import datetime
PATH = r"C:\Program Files (x86)\chromedriver.exe" # Path where u have downloaded the driver
driver = webdriver.Chrome(PATH)
driver.get("https://www.google.com")
This will work hopefully!
Upvotes: 1
Reputation: 96
Try this with your correct driver path
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time
import datetime
chromedriver = 'path of chrome driver till chromedriver.exe'
driver = webdriver.Chrome(chromedriver)
driver.get("https://www.google.com/")
Upvotes: 1