Selenium | How to iterate | TypeError: ‘WebElement’ object is not iterable

Please find the attached screenshot below i want to fetch the rows i.e all tweets rows. i struggling to how to iterate and fetch all rows.

enter image description here

Below code i have tried.

driver.get("https://www.trackmyhashtag.com/")

form = driver.find_element_by_xpath("//*[@class='container']")
usrinput = driver.find_element_by_xpath('/html/body/header/div[2]/div/div[2]/form/div/div[1]/input')
usrinput.clear()
usrinput.send_keys("india")

loginbt = driver.find_element_by_xpath('/html/body/header/div[2]/div/div[2]/form/div/div[2]/button')
loginbt.click()
time.sleep(5)

ad = driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[3]/div/div/div/button')
ad.click()
time.sleep(5)

element = driver.find_element_by_xpath('/html/body/aside/nav/div/ul/li[2]/a')
actions = ActionChains(driver)
actions.move_to_element(element).perform()
actions.click().perform()
time.sleep(5)

ad=wait.until(driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[3]/div/div/div/button'))

row = driver.find_element_by_xpath('/html/body/div[1]/div[1]/div[1]/div[5]/div/div/div/div[2]/div')

for i in row:
    i.get_attribute('td')
    print(i)

print("inside it")

Answer

To get all the tweets rows you can use this

rows = driver.find_elements_by_xpath("//tr[@role='row' and(@class)]")

Now to get, for example, the tweets names you can do this:

actions = ActionChains(driver)

rows = driver.find_elements_by_xpath("//tr[@role='row' and(@class)]")
for i in range(1,len(rows)+1):
    row = driver.find_element_by_xpath("(//tr[@role='row' and(@class)])[" + str(i) + "]")
    actions.move_to_element(row).perform()
    time.sleep(1)
    row = driver.find_element_by_xpath("(//tr[@role='row' and(@class)])[" + str(i) + "]")
    name = row.find_element_by_xpath(".//div[@class='tweet-name']").text
    content = row.find_element_by_xpath(".//td[2]").text
    date = row.find_element_by_xpath(".//td[2]").text
    impressions = row.find_element_by_xpath(".//td[6]").text

To use actions you will need to import

from selenium.webdriver.common.action_chains import ActionChains