CCCPaste

Populate Google Form

import random
import string
import time
from selenium import webdriver

def get_random_letters():
    names = string.ascii_letters
    return random.choice(names).upper() + random.choice(names).upper()

def fill_personal_data():
    text_input = driver.find_elements_by_class_name('quantumWizTextinputPaperinputInput.exportInput')

    # Fill Name Input
    name = text_input[0]
    name.send_keys(get_random_letters())

    university = text_input[2]
    univ_names = ['Universitas Tarumanagara', 'BINUS University', 'Trisakti School of Management', 'Atma Jaya']
    university.send_keys(random.choice(univ_names))

def choose_random_radios():
    radio_student = driver.find_element_by_id('i13')
    radio_assistant = driver.find_element_by_id('i16')

    is_student = random.randrange(5)
    if is_student <= 3:
        radio_student.click()
    else:
        radio_assistant.click()

def choose_random_traits(questions):
    radio = driver.find_elements_by_class_name('appsMaterialWizToggleRadiogroupEl')
    
    for i in range(questions):
        choosen = random.choices(population=[0, 1, 2, 3], weights=[0.1, 0.1, 0.4, 0.4])
        radio[i*3 + choosen[0] + i].click()



num_of_times = 10
driver = webdriver.Edge('C:\msedgedriver.exe')

for i in range(num_of_times):
    driver.get('https://docs.google.com/forms/d/e/1FAIpQLSezymJcusO6GfRKg-o2xVrcjRqhyU9xWYWl4y0kfaAZDNBNkQ/formResponse')

    firstPageSubmit = driver.find_element_by_css_selector("span.quantumWizButtonPaperbuttonLabel.exportLabel")
    firstPageSubmit.click()

    fill_personal_data()
    choose_random_radios()

    driver.find_elements_by_css_selector('span.quantumWizButtonPaperbuttonLabel.exportLabel')[2].click()

    choose_random_traits(4)

    driver.find_elements_by_css_selector('span.quantumWizButtonPaperbuttonLabel.exportLabel')[1].click()

    choose_random_traits(5)

    driver.find_elements_by_css_selector('span.quantumWizButtonPaperbuttonLabel.exportLabel')[1].click()