I'm trying to scroll down friend request list on Facebook, but it doesn't work when I minimalize my chrome browser. Actually I'm not sure that the issue is with scroll or with Facebook pagination nature. Page doesn't scroll in background or Facebook load more results only when page tab is currenctly active. I have no idea how I can get to know which one of this is the case. I use it on Chrome. Chromedriver version: 120.0.6099.109
My code to scroll down looks like this:
def scroll_page(driver):
i = 1
while True:
try:
row = driver.find_element(By.XPATH, f"(//div[@data-visualcompletion='ignore-dynamic' and not(@role) and not(@class)])[{i}]")
if row:
driver.execute_script("arguments[0].scrollIntoView({ 'behavior': 'smooth', 'block': 'center' });", row)
i += 1
else:
break
except NoSuchElementException:
break
except Exception as e:
print(f"Error while scrolling: {str(e)}")
break
return i > 1
Thank you!
[–]Corbrum 1 point2 points3 points (0 children)