Selenium Web Scraper for E-commerce Site Yields No Output or Errors

Using Selenium to fetch product information from an online store produces no data even though the browser opens. See revised sample code below:

from selenium import webdriver
from selenium.webdriver.common.by import By
import time, json

drvr = webdriver.Chrome()
drvr.minimize_window()
drvr.get('https://exampleecom.com/items')
time.sleep(10)

cards = drvr.find_elements(By.XPATH, "//div[@class='item-card']")
extracted = []
for card in cards:
    try:
        name = card.find_element(By.XPATH, './/h2').text
    except Exception:
        name = ''
    try:
        cost = card.find_element(By.XPATH, './/span[@class="amount"]').text
    except Exception:
        cost = ''
    extracted.append({'name': name, 'price': cost})

with open('results.json', 'w') as fout:
    json.dump(extracted, fout)

drvr.quit()

Need guidance to resolve this issue.

hey try using explicit waints instead of sleep, xpaths might be off if js content loads later. check if the elements are fully rendered before scraping. hope it hlps!