This is a weird one, I am trying to get product names and price from a website using selenium in Python. I am able to get the price but getting the unable to locate element error for product name.
I am using very similar code for both these items :
s3 = driver.find_element(By.CSS_SELECTOR, "span.weight-tile__PriceText-otzu8j-5.hJFddt")
print(s3.text)
s = driver.find_element(By.CSS_SELECTOR, "span.mobile-product-list-item__ProductName-zxgt1n-6.hBmGOx")
print(s.text)
>Solution :
css selector is trying to find the class which is valid for mobile size. If you want to find the element, make sure that the browser has mobile dimensions. Or if you want to catch the titles in the desktop version, in your case it is
s = driver.find_element(By.CSS_SELECTOR, "span.desktop-product-list-item__ProductName-sc-8wto4u-7.kjymBK")