Python Selenium not letting me sign in to ancestry

Question:

I have used selenium and the chromedriver to sign in to ancestry.com, however it says that it is not finding the id for login information. It opens up the browser and goes to the page, put the does populate and login. I have tried this on other sites yet it has worked, not sure why it is not working here. I had tried to make it sleep for a few seconds thinking the page needed to load fully (coming from my beginners knowledge)….Code is below, I would appreciate if anyone has had trouble or knows how to deal with this login.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep

chrome_path= r"C:Users....chromedriver_win32chromedriver.exe"
driver= webdriver.Chrome(chrome_path)
driver.get("https://www.ancestry.com/account/signin")
sleep(15)

username= "username"
password= "password"
driver.find_element_by_id("username").send_keys(username)
driver.find_element_by_id("password").send_keys(password)
driver.find_element_by_id("signInBtn").click()
print("Logged in Successfully")
Asked By: rlearner

||

Answers:

Actually, you need to switch to the frame, I’ve used the explicitWait instead of sleep

driver.get("https://www.ancestry.com/account/signin")

username= "username"
password= "password"

WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it(driver.find_element_by_id("signInFrame")))

userName = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"username")))
userName.send_keys(username)

passWord = WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.ID,"password")))
passWord.send_keys(password)

signIn = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.ID,"signInBtn")))
signIn.click()

print("Logged in Successfully")
Answered By: YaDav MaNish