0

on this website https://www.firstbankcard.com/lynx/#/pre-qual/intake?agent=H48&sub=000 i am trying to send keys to the first name field using this code

driver5 = webdriver.Chrome(options=chrome_options)
driver5.get('https://www.firstbankcard.com/lynx/#/pre-qual/intake?agent=H48&sub=000')
#fnbo first name
fnbofname = driver5.find_element(By.XPATH, '//*[@id="firstName"]')
fnbofname.send_keys(fname)

but i instead get this error returned

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="firstName"]"}

i did notice there was a couple iframes on the site but i dont know if they would affect my code hence why i am asking here if anyone can give me pointers/ examples as i feel like i keep running into what i think are problems cause by iframes but i dont know how to deal with them since they are not directly in the html text i am trying to copy

thrvxx
  • 33
  • 4

1 Answers1

1

The desired element is a Angular element, so ideally to send a character sequence to the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using CSS_SELECTOR:

    driver.get("https://www.firstbankcard.com/lynx/#/pre-qual/intake?agent=H48&sub=000")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#firstName"))).send_keys("thrvxx")
    
  • Using XPATH:

    driver.get("https://www.firstbankcard.com/lynx/#/pre-qual/intake?agent=H48&sub=000")
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='firstName']"))).send_keys("thrvxx")
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
  • Browser snapshot:

lynx

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352