I am new to using Python with Selenium, and I am having trouble with scraping a code from a web.
I don't want anybody to fix it for me. I am looking for a hand on what the problem might be, so that I can proceed.
# inicializar el paketito selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox()
driver.get("http://www.codigosdescuento.com/categoria-accesorios_de_moda.html")
boton_promo = driver.find_element_by_xpath("//a[contains(@class,'boton_descuento')][1]")
boton_promo.click()
#buscamos el codigo
try:
WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='rasca_cupon']")))
except:
print("K va... no se ha encontrado el codigo")
raise SystemExit
codigo_descuento = driver.find_element_by_xpath("//div[@class='rasca_cupon']")
print(codigo_descuento.text)
It prints the exception, even though the expected element exists and gets visible.
How can I know what makes the driver not see the element?