I want to use Selenium on Python but I have an alert message:
driver-webdriver.Chrome("D:\\Selenium\\Chrome\\chromedriver.exe") NameError: name 'driver' is not defined
I have installed the Chrome Driver, what else must I do ?
chromedriver.exe must be in python path, probably now python expects that driver exists in "D:\\Selenium\\Chrome\\chromedriver.exe" but it does not. You could try add chromedriver.exe path to windows enviroment path variable, or add path to os.path in python, or add driver to folder of python script.
driver = webdriver.Chrome(path_to_your_chromedriver.exe)
If chromedriver is in your PATH you dont have to specify. Remember to use double slashes - or put an r in front of the chromedriver path
... = webdriver.Chrome(r'path_without_doubble_slashes)
Here is the Answer to your Question:
While working with Selenium
3.4.3, chromedriver
v2.30 and Google Chrome
v59.0 through Python 3.6.1
you neither need to install chromedriver
nor need to copy in to any path
. You can save the chromedriver
in any location on your machine. To initiate the WebDriver instance you can explicitly call the chromedriver
by passing the absolute path of the chromedriver
through the argument executable_path
as follows:
from selenium import webdriver
driver = webdriver.Chrome(executable_path= r'C:\\Utility\\BrowserDrivers\\chromedriver.exe')
Let me know if this Answers your Question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.