Selenium send_keys() not working sometimes

Viewed 14

I have been trying to automate filling input boxes on this web form.

I have set code to wait for the webpage to finish loading, however, the process of sending keys sometimes works, and most times it doesn't. What am I doing wrong?

Here is my code

import os
import time
from selenium import webdriver
from selenium .webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait


#inputs
email = "test@test.com"
first = "nyau"
last = "paka"
date_dob = "09"
month_dob = "24"
year_dob = "1990"
zip = "1234"
password = "Password"



#opening browser
driver = webdriver.Chrome("C:/seleniumDriver/chromedriver.exe")

driver.get("https://apply.ctc.edu/register")

time.sleep(60)

input_username = driver.find_element(By.ID,"userName")
input_password = driver.find_element(By.ID,"pass")
input_confirm = driver.find_element(By.ID,"cnfpass")
input_first = driver.find_element(By.ID,"firstName")
input_last = driver.find_element(By.ID,"lastName")
input_dob = driver.find_element(By.ID,"mat-input-6")
input_email = driver.find_element(By.ID,"mat-input-7")

submit_button = driver.find_element(By.CLASS_NAME,"btn btn-primary")



#creating username

username = first + last

#creating dob
dob = month_dob + "/" + date_dob + "/" + year_dob


#inputting
input_username.send_keys(username)
input_password.send_keys(password)
input_confirm.send_keys(password)
input_first.send_keys(first)
input_last.send_keys(last)
input_dob.send_keys(dob)
input_email.send_keys(email)



print("done")
0 Answers
Related