How can I scroll with selenium if I already follow a user?
This part of your code does not make sense:
buttons = driver.find_element_by_xpath("//*[text()='Follow']")
scroll = 0
sleep(10)
fBody = driver.find_element_by_xpath("//div[@class='isgrP']")
for btn in buttons:
if btn.text == 'Follow':
driver.execute_script("arguments[0].click();", btn)
sleep(60)
else :
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop + arguments[0].offsetHeight;', fBody)
Please be aware, that first you are getting all elements with text 'Follow' to buttons
, then you check if text of each element is in fact equal to Follow
. Try to find different locator for those buttons, e.g.
//div[@aria-label='Followers']//ul//button
with this, you will get list of buttons (with and without 'Follow' text), then you can perform your actions depending if text equals 'Follow'.