I am trying to get the Add Ons from this page. If the item is customisable.
After collecting all the divs, I try to go to the top of the page(Doesn't work). I check if the customisable div is present. If so, scroll it into view, click the Add button and get Add on details. I have tried, actionChains, didn't work. execute_script also does nothing. The click was working before but the scrolling up and down the page kind of messed it up. Been trying to get this right for hours. Any help is greatly appreciated.
for i in range(6):
item_dvs = driver.find_elements_by_class_name('_2wg_t')
driver.execute_script("window.scrollBy(0, 3100)")
driver.execute_script("window.scrollBy(0,-18500);")
for div in item_dvs:
try:
name = div.find_element_by_class_name('styles_itemNameText__3bcKX')
price = div.find_element_by_class_name('rupee')
if div.find_elements_by_class_name('styles_itemDesc__MTsVd'):
desc = div.find_element_by_class_name('styles_itemDesc__MTsVd').text
else:
desc = None
is_cust = div.find_element_by_class_name('_1C1Fl _23qjy')
if is_cust:
driver.execute_script("arguments[0].scrollIntoView();", is_cust)