I need to see if a div with a particular class name has an image inside it. I am using.
picUrl=[]
eachDiv =self.find_elements(By.XPATH,"//div[@class='NiLAwe y6IFtc R7GTQ keNKEd j7vNaf nID9nc']")
for index, individualDiv in enumerate(eachDiv):
if(individualDiv.find_element(By.XPATH,"//img[@class='tvs3Id QwxBBf']").get_attribute('src')):
picUrl.append(individualDiv.find_element(By.XPATH,"//img[@class='tvs3Id QwxBBf']").get_attribute('src'))
print('present')
else:
picUrl.append(" no pic ")
print('not')
return picUrl
but the condition never reaches inside the else condition even if the div doesn't have a tag with that class name.