【发布时间】:2021-03-25 06:34:37
【问题描述】:
我是 python 新手,目前正在处理结帐页面上的自动提交。我知道该元素在 iframe 内,因此我改用了 By.Xpath,"//iframe。
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
WebDriverWait(driver, 15).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@id='newCard']")))
WebDriverWait(driver, 15).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='newCard' and @id='newCard']"))).send_keys("4242424242424242")
但我仍然在下面收到此错误。
Traceback (most recent call last):
File "C:\Users\USER\Desktop\Python Scripts\Nike_autologin_autofill_v2.py", line 44, in <module>
WebDriverWait(driver, 15).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@id='newCard']")))
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
【问题讨论】:
-
你能添加你的 iframe 的 HTML 标签吗?
标签: python selenium iframe webdriverwait timeoutexception