'Exception has occurred: NoSuchElementException - iframe will not work

from discord_webhook import DiscordEmbed, DiscordWebhook
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.common.exceptions import NoSuchElementException
import time
import random
import csv


# Opens the form
driver.execute_script("window.open('');")# Switch to the new window and open URL 2
driver.switch_to.window(driver.window_handles[1])
url2 = "https://vrlps.co/oms1t1m/cp"
driver.get(url2)
print('worked url2')
driver.implicitly_wait(2)


#Stops working at this part


driver.find_element(By.XPATH, "//input[@id='firstname']//iframe").send_keys(str(firstname))
driver.find_element(By.XPATH, "//input[@id='lastname']//iframe").send_keys(str(lastname))
driver.find_element(By.XPATH, "//input[@id='email']/iframe").send_keys(str(email))
driver.find_element(By.XPATH, "//button[@id='participationSubmitNoReferrer']//iframe")

driver.switch_to.default_content()

I get there error whenever I try run the program and use driver.find_element(By.XPATH, "//input[@id='firstname']//iframe").send_keys(str(firstname)) I don't know why the iframe won't work.

I've tried this as well

driver.switch_to.frame(driver.find_element(By.XPATH, '//*[@id="ndx4LHot9i4FdzIy0ePoc4MYOV4_embedForm_kc1myl"]//iframe'))

I'm trying to figure out why I can't just go to the iframe directly without it bugging out and filling out the form. I've tried using different types like CSS and that doesn't work either, everything else works but that single iframe is what stops it.

Keep in my mind in the original code (had to trim it due to it being considered spam). All the variables work and everything the code just stops at the iframe.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source