Selenium Python Code

This script can now navigate directly to this view using the URL hash.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import time

driver = webdriver.Chrome()

# Navigate directly to the web form view
# by appending '#web' to the URL
file_path = "https://bayujunisp.github.io/practice/webautomation.html"
driver.get(file_path + "#web")

# --- Example of a VALID submission ---
driver.find_element(By.ID, "username").send_keys("testuser")
driver.find_element(By.ID, "email").send_keys("valid@email.com")
driver.find_element(By.ID, "password").send_keys("password123")
driver.find_element(By.ID, "radio2").click() # Liverpool
driver.find_element(By.ID, "checkbox1").click() # Sepak Bola
select_element = Select(driver.find_element(By.ID, "dropdown"))
select_element.select_by_visible_text("NUS")
driver.find_element(By.ID, "submit-btn").click()
time.sleep(3)

driver.quit()

Practice Form

Form Submission Results

UsernameEmailPasswordKlub TerbaikOlahragaUniversity

Step 1: Python CSV Generator

import csv, os
users_data=[['id','name','email'],['1','Bruno Fernandez Doe','bruno@mu.com'],['2','Casemiro','casemiro@mu.com']]
file_path='users.csv'
with open(file_path,'w',newline='')as f:csv.writer(f).writerows(users_data)
print(f"'{file_path}' created at: {os.path.abspath(file_path)}")

Step 2: Selenium Upload Script

import os, time
from selenium import webdriver
from selenium.webdriver.common.by import By
csv_file_path=os.path.abspath('users.csv')
if not os.path.exists(csv_file_path):raise FileNotFoundError("Run generator first!")
driver=webdriver.Chrome()
file_path="https://bayujunisp.github.io/practice/webautomation.html"
driver.get(file_path + "#upload")
time.sleep(1)
file_input=driver.find_element(By.ID, "csv-upload-input")
file_input.send_keys(csv_file_path)
time.sleep(5)
driver.quit()

CSV Upload Practice

Use Selenium to upload the generated users.csv file.

Uploaded CSV Data

Uploaded data will appear here...