I try to autofollow people that are commenting under various pictures and im on the step where i need to hover over profile names to let a window popup
(u can try it yourself to see what i mean(https://www.instagram.com/p/CLMCNSenf-E/ hover ur mouse over a name)),
but when i use the "move_to_element" command it shows me the error message raise AttributeError("move_to requires a WebElement"). I dont really understand the meaning of it, can someone help me out? I posted the code below. Dont forget to replace the fillers with ur own login information if u want to try it out.
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains
browser = webdriver.Chrome()
action = ActionChains(browser)
url = "https://www.instagram.com/"
browser.get(url)
sleep(1)
browser.find_element_by_xpath("/html/body/div[2]/div/div/div/div[2]/button[1]").click()#popup
#Login
browser.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[1]/div/label/input")\
.send_keys("username")
browser.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[2]/div/label/input")\
.send_keys("password")
browser.find_element_by_xpath("/html/body/div[1]/section/main/article/div[2]/div[1]/div/form/div/div[3]/button").click()
sleep(3)
browser.find_element_by_xpath("/html/body/div[1]/section/main/div/div/div/div/button").click()#popup
browser.find_element_by_xpath("/html/body/div[4]/div/div/div/div[3]/button[2]").click()#popup
url = "https://www.instagram.com/scarlxrd/"
browser.get(url)
browser.find_element_by_xpath("/html/body/div[1]/section/main/div/div[3]/article/div/div/div[1]/div[1]/a/div/div[2]").click()#Bildwahl
sleep(2)
follow = "/html/body/div[6]/div/div/div[4]/button"
a = 1
for i in range(5):
for i in range(1, 11):
link = "/html/body/div[5]/div[2]/div/article/div[3]/div[1]/ul/ul[{a}]/div/li/div/div[1]/div[2]/h3/div/span/a".format(a=i)
action.move_to_element(link).move_to_element(follow).click().perform()
sleep(1)