This error message...
AttributeError: module 'selenium.webdriver.firefox' has no attribute 'find_element_by_name'
...implies that the selenium.webdriver.firefox has no attribute as find_element_by_name
.
You need to consider a couple of things as follows:
To initialize a Firefox session you need to change the line of code drivers = webdriver.firefox
into proper format as:
drivers = webdriver.Firefox()
find_element_by_name()
method can locate the element only when the HTML DOM is loaded. So, you need to invoke get(url)
and load the DOM Tree before invoking find_element_by_name()
as follows:
drivers.get("http://digitalsaf.com/")
Your effective code block will be:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://digitalsaf.com/")
elem = driver.find_element_by_name("username")