1

Im new to python and currently working on an auto submission on a checkout page. I understand that the element is within the iframe hence I have used By.Xpath,"//iframe instead.

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")

But im still getting this error below.

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: 

enter image description here

Parolla
  • 408
  • 2
  • 6
Ben
  • 11
  • 1

1 Answers1

0

"iframe.newCard" CSS-selector means iframe node with class name 'newCard'

You need to specify @class instead of @id. Try to replace

"//iframe[@id='newCard']"

with

"//iframe[@class='newCard']"
Parolla
  • 408
  • 2
  • 6