1

I'm using this to populate a list(wordlist) from Amazon website product page hoping to get this text "Haz clic para obtener una vista ampliada" :

wordlist.append(WebDriverWait(robotel, 30).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "span#canvasCaption"))).text)

Problem is that when I do it in a loop, for multiple product pages sometimes for some products wordlist is empty, but then if I test again for the same product page wordlist gets populated.

I can't fiind the reason for this, so please help.

petezurich
  • 9,280
  • 9
  • 43
  • 57
madacmjtr
  • 13
  • 6

1 Answers1

0

Your line of code seems just perfect.

However, to avoid the empty wordlist you can additionally implement either/all of the following approaches:

  • As you are iterating through a loop some product pages and some products may take longer time to render, so you may need to increase the waiting time for 30 secs to 45 secs,
  • Beside considering the id attribute you can append some other attributes as well, e.g. class, aria-label, href, data-a-hires, alt, etc
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I can't fiind any other diffrence between 2 product pages : one which has zoom function (you can move the mouse over picture to see it zoomed in) and one which has no zoom function. I will give it a try with longer waiting time, thank you ! – madacmjtr Feb 10 '22 at 05:41