Issue
I understand that this question has been asked a lot in one way or another, however, I have tried finding elements on selenium with every type that I have at my disposal and it keeps giving me the error:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
Am I just grossly misusing selenium or is it the website? I honestly just want to select the element so that I can start working with it for some practice code that I am doing. Here is my code:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
import time
email = '[email protected]'
options = Options()
options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
service = Service("/Users/NAME/Desktop/job_stuff/chromedriver")
driver = webdriver.Chrome(options = options, service=service)
driver.get('https://www.hgtv.com/sweepstakes/hgtv-urban-oasis/sweepstakes')
is_open = True
time.sleep(5)
# inputField = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,'//*[@id="xReturningUserEmail"]')))
inputField = driver.find_element(By.XPATH, '/html/body/div[1]/div/main/section/div/div/div/div/div/div[1]/div/form/div[1]/fieldset/div/div[2]/div[1]/input')
Solution
It is an iframe.
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it(driver.find_element(By.XPATH, ".//*[starts-with(@id,'ngxFrame')]")))
driver.find_element(By.XPATH,".//input[@type='email' and @id='xReturningUserEmail']").send_keys("[email protected]")
Answered By - AbiSaran
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.