Selenium Python driver.find.elements get attribute

Viewed 253
def n_seguidores(self, username):
    driver = self.driver
    driver.get('https://www.instagram.com/'+ username +'/')
    time.sleep(3)
    user_botao = driver.find_elements_by_class_name('g47SY ')
    print_us = user_botao.get_attribute('title')
    print(print_us)

please help me to find numbers of following from html

1 Answers

.find_elements_* return a list, so you need access by index.

There are 3 numbers with the same class name in the page, and the numbers of following you mean is the third.

And to get the number you can use .text, not .get_attribute('title')

Try following code:

user_botao = driver.find_elements_by_class_name('g47SY ')
#second index
print_us = user_botao[2].text
print(print_us)
Related