2

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 ?

1
  • Share the import statements Commented Jul 6, 2017 at 9:23

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

1
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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.