I want to get web elements with the same class name. I'll use those to take screenshots of elements for my application. I am using Selenium in Python for this purpose.
url = "https://www.pexels.com/search/happy/"
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())
driver.get(url)
elements = driver.find_elements(By.CLASS_NAME, "MediaCard_image__ljFAl")
print("**** Start *******")
print(elements.count)
for element in elements:
print("1")
print(element.text)
print("**** End *******")
output is:
**** Start *******
<built-in method count of list object at 0x00000250202F2000>
1
1
1
1
1
1
1
1
**** End *******
I think element.text
is empty, but why? There are many elements with this class name. Can anyone offer some help?