I am scraping a Twitter page using Selenium and my scraped tweets are stored in a list variable tweets
. I can iterate through them normally and extract the text from them using:
for tweet in tweets:
print(tweet.text)
However, when I try to use list comprehension and do
[tweet.text for tweet in tweets]
I get a StaleElementReferenceException
StaleElementReferenceException: Message: The element reference of [object String] "b22c079f-684f-4d46-942b-d5dd69203728" is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
Why is this happening?