0
私は新規使用PythonとSeleniumを使用しています。Webからコードをスクラップする際に問題があります。Python +セレニウム非検出要素
私は誰も私のためにそれを修正したくありません。私は問題がどうなっているのかを探しているので、進めることができます。
# 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)
予想される要素が存在し、表示されても、例外が出力されます。
ドライバで要素が表示されないのはどうすればわかりますか?
switch_to_window()
はどうもありがとうございました追加した後に完全に取り組んでいます。 .switch_to_windowが.switch_to.windowのために推奨されなくなりました。 –