I am new to selenium python, how to scroll down to the bottom of the filter in swiggy. When I tried the background page is getting scroll instead of filter. enter image description here
CodePudding user response:
First you have to be sure to target the correct element, in this case the side menu, then with javascript you can edit its scroll level. Run the last line of the code below many times if you want to scroll more
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
chromedriver_path = '...'
driver = webdriver.Chrome(service=Service(chromedriver_path))
...do something...
side_menu = driver.find_element(By.CSS_SELECTOR, 'div._3vi_e')
driver.execute_script('arguments[0].scrollTop = arguments[0].scrollTop arguments[0].offsetHeight;', side_menu)