2

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?enter image description here

1 Answer 1

1

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.