Debug School

rakesh kumar
rakesh kumar

Posted on

Selenium Error:name 'driver' is not defined

my code is
designation=driver.find_element(By.CLASS_NAME,"suggestor-input")
when i run it i got error

NameError                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 designation=driver.find_element(By.CLASS_NAME,"suggestor-input")
      2 designation.send_keys('Data Analyst')

NameError: name 'driver' is not defined
Enter fullscreen mode Exit fullscreen mode

Solution
step1:

pip install --upgrade selenium
Enter fullscreen mode Exit fullscreen mode

update the selenium to recent version 4.11.2, it will automatically download the recent driver do not need to update driver manually

step2:

before updating selenium delete the previous webdriver in C drive. in environment variable also

step3: then use command

driver=webdriver.Chrome()
Enter fullscreen mode Exit fullscreen mode

step4 run the commands
driver.get("https://www.naukri.com/")

then we will one browse automatically open
Image description

Another solution
from selenium import webdriver
driver = webdriver.Chrome(executable_path= r'C:\Utility\BrowserDrivers\chromedriver.exe')

Top comments (0)