Python and how to get text from Selenium element WebElement object?

Once you locate the element you can use the text property.

Example:

for element in self.driver.find_elements_by_tag_name('img'):
       print element.text
       print element.tag_name
       print element.parent
       print element.location
       print element.size

Selenium Get Text From Element (just add ".text")

1

for all elements of the list

tree = browser.find_elements_by_xpath(<the_XPATH>)
for i in tree:
   print(i.text) 

2

[ ] fetchby number

 tree = browser.find_elements_by_xpath(<the_XPATH>)
 print(tree[0].text)