Reputation: 3
Trying to learn Selenium for Python (3.4.0) and have had success with the basic things - installing, opening browser and web page, so on. But when I try to open a specific HTML form I am met with an error - something to do with the 'driver' at the beginning of the 'driver.find_element_by_name'.
My code is:
#vocab express logger onner
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
browser=webdriver.Firefox()
browser.get("https://www.vocabexpress.com/login/")
uname = driver.find_element_by_name("uname")
uname.send_keys("13holmee")
and the error message is:
uname = driver.find_element_by_name("uname")
NameError: name 'driver' is not defined
Sorry if this too simple a question or has been asked before (I couldn't find anything), I'm still new to this.
Thanks
Upvotes: 0
Views: 1092
Reputation: 402
There is no driver
in your namespace, because you have not defined a variable with that name.
find_element_by_name
is a method of the webdriver.Firefox
object, which in this case you have named browser
. Try uname = browser.find_element_by_name("uname")
.
Upvotes: 1