TypeError: 'WebElement' object is not iterable error
Below code worked for me.
from selenium import webdriver
driver=webdriver.Firefox()
driver.get("https://www.google.co.in/")
list_links=driver.find_elements_by_tag_name('a')
for i in list_links:
print i.get_attribute('href')
The problem is that you are using find_element_by_xpath
which return only one WebElement (which is not iterable), the find_elements_by_xpath
return a list of WebElements.
Solution: replace find_element_by_xpath
with find_elements_by_xpath
Reference: selenium-python docs