So as you know, when you open a post on Instagram on Desktop, it will show "Liked by someone and 400 others". I am trying to click the "400 others" button using selenium, so that I could then go on to scrape the followers' names.
I retreived the Xpath of the button as /html/body/div1/section/main/div/div/article/div[2]/section[2]/div/div[2]/button
However, an error arises, which is the StaleElementReferenceException. Below are my codes:
likes = driver.find_element_by_xpath("/html/body/div[1]/section/main/div/div/article/div[2]/section[2]/div/div[2]/button")
actions.move_to_element(likes).perform()
likes.click()
The error happens on the 2nd line, actions.move_to_element(likes).perform()
I wonder whether anyone knows how I can fix it.