Issue
When I try to select all the items in filter, it is selected only when I scroll it manually if not only few options which is visible without scrolling is getting selected, How to select all the options in swiggy filter in cuisine?
Solution
This code loops over the list of filters and scrolls down when necessary using javascript.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
driver = webdriver.Chrome(service=Service(chromedriver_path))
...do something and then open the Filters sidebar...
# loop over the filters and scroll if necessary
for box in driver.find_elements(By.CSS_SELECTOR, 'input[type=checkbox] + span'):
driver.execute_script('arguments[0].scrollIntoView({block: "center"});', box)
box.click()
Answered By - sound wave
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.