There are 41 category checkbox, 12 are visible and remain are hidden, need to click on show more to show hidden checkboxes.
this code do that:: 1-loop >> 2-click on show more if i <=12 >> 3-click on checkbox
# -*- coding: utf-8 -*-
import time
from selenium import webdriver
driver = webdriver.Chrome(executable_path='C:\\Users\\Compu City\\Desktop\\chromedriver.exe')
driver.get('https://www.amazon.com/international-sales-offers/b/?ie=UTF8&node=15529609011&ref_=nav_navm_intl_deal_btn')
time.sleep(10)
res = driver.execute_script("return document.documentElement.outerHTML")
i=0
while i <= 41 :
if(i <=12):
driver.find_element_by_css_selector('#widgetFilters > div:nth-child(1) > div.a-row.a-expander-container.a-expander-inline-container > a > span').click()
driver.find_elements_by_css_selector('.a-expander-container .a-checkbox label .a-label')[i].click()
driver.implicitly_wait(2)
time.sleep(2)
i+=1
the problem: code works well with 12 checkboxes and then click on show more then click just on the first checkbox NO.13 then get this error
D:\python neww>aaa.py
DevTools listening on ws://127.0.0.1:59799/devtools/browser/ac2188e0-10e3-493b-9d91-614731f8d135
Traceback (most recent call last):
File "D:\python neww\aaa.py", line 14, in <module>
driver.find_elements_by_css_selector('.a-expander-container .a-checkbox label .a-label')[i].click()
IndexError: list index out of range
i searched a lot about selution what i found that echeckbox not load , but when change .click() with .text
I get all checkbox label names, so how they don't load