Printing Text from Element Selenium Python Printing Text from Element Selenium Python selenium selenium

Printing Text from Element Selenium Python


You can use the below xpath :

//a[contains(@href, 'followers')]/span

and there isn't any GetAttribute method available in Selenium - Python binding.

Instead you can use :

followers = driver.find_element_by_xpath("//a[contains(@href, 'followers')]/span").get_attribute("innerHTML")print("Followers: ", followers)


Can you check this

followerTxt=driver.find_element_by_xpath("((//a[@class='-nal3 ']/span)[2])")print("Total followers: ",followerTxt.text)

I've check based on the element index

enter image description here

This is my Output