selenium text returns empty string python

new_name = driver.find_element_by_xpath(xp_name).get_attribute('textContent')

Here is what the above code is Doing:
1. It’s finding the element with the xpath of xp_name.
2. It’s getting the textContent attribute of that element.
3. It’s assigning that textContent to the variable new_name.