Automatic Submission of Sign Up Form
Write a program that automatically fill and send the form below with random information
Help: You can use selenium
Write a program that automatically fill and send the form below with random information
Help: You can use selenium
You can use the following code to fill out and submit the form using Selenium:
from selenium import webdriver
from selenium.webdriver.common.by import By
import random
import time
# Browser Settings
driver = webdriver.Chrome()
# Open the form page
driver.get('file:///path/to/your/form.html') # Enter your HTML file address
# Production of Random Information
name = f"User{random.randint(1, 100)}"
email = f"user{random.randint(1, 100)}@example.com"
password = "password123"
# Fill the form
driver.find_element(By.ID, 'name').send_keys(name)
driver.find_element(By.ID, 'email').send_keys(email)
driver.find_element(By.ID, 'password').send_keys(password)
driver.find_element(By.ID, 'confirm-password').send_keys(password)
# Send the form
driver.find_element(By.XPATH, '//button[text()="ثبتنام"]').click()
# Wait a little to see the result
time.sleep(5)
# Close the browser
driver.quit()
Note: Be sure to address the html file on the linedriver.get()Enter.
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.