Second ever post here. Still new to all this. Having trouble with a simple print call in a for loop not displaying any text, yet moving the cursor as if it did. If I check the length, it matches with how many spaces are moved in the print call (12)
from selenium import webdriver
from selenium.webdriver.common.by import By
browser= webdriver.Chrome()
browser.get('https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dcomputers-intl-ship&field-keywords=&ref=nb_sb_noss&crid=JKZZMSQ4Q71E&sprefix=%2Ccomputers-intl-ship%2C114')
elem_list= browser.find_element(By.CSS_SELECTOR, "div.a-section.a-spacing-medium._octopus-search-result-card_style_apbSearchResultsContainer__bCqjb")
items = elem_list.find_elements(By.XPATH, '//span[@data-component-type="s-product-image"]')
for item in items:
print(item.text)
if I run
print(len(items))
I get 12. However once I run the above mentioned for loop, I simply get 12 blank empty spaces. What am I doing wrong?
Update
I'm thinking the problem is in the data component type being an image. But after inspecting all the elements, what's best practice for displaying the list of items on the page that I am trying to do?