This project is a Python bot that automatically fills out a specific Google Form multiple times. It uses Selenium for web browser automation and the Google Gemini API to generate unique, human-like answers for the text-based questions.
-
Automated Form Submission: Fills out a multi-page Google Form from start to finish.
-
AI-Powered Answers: Uses the Google Gemini API to generate unique responses for open-ended questions.
-
Multi-Run Capability: The main script can be configured to run
Ntimes, submitting the form multiple times in a row. -
Handles Various Inputs: Fills out radio buttons, checkboxes, multi-selects, text areas, and grid-based ratings.
-
Clean Code Structure: The project is split into logical files:
-
main.py: The main entry point. Handles setup, teardown, and looping. -
bot.py: Contains theFormBotclass with all the core automation logic. -
config.py: Stores all constants like the form URL, AI prompts, and ratings. -
utils.py: Contains helper functions for setting up the AI model and Selenium driver.
-
-
Selenium for browser automation.
-
google-generativeai for access to the Gemini API.
-
python-dotenv for managing environment variables.
-
Firefox & Geckodriver
git clone [https://github.com/Shinkrbs/forms-automate.git](https://github.com/Shinkrbs/forms-automate.git)
cd forms-automate
It's highly recommended to use a virtual environment:
# Create a virtual environment (macOS/Linux)
python3 -m venv venv
source venv/bin/activate
# Create a virtual environment (Windows)
python -m venv venv
.\venv\Scripts\activate
# Install the required packages
pip install -r requirements.txt
This script is configured to use Firefox, so you need geckodriver.
-
Download: Download the latest
geckodriverfor your operating system from the official releases page. -
Install: Unzip the file and move the
geckodriverexecutable to a location in your system'sPATH.-
macOS/Linux: A good place is
/usr/local/bin/.sudo mv geckodriver /usr/local/bin/ -
Windows: You can add the folder where you extracted
geckodriverto your system's "Environment Variables" PATH.
-
IMPORTANT: Your geckodriver version must be compatible with your installed Firefox version. If you get errors, the first thing to check is this mismatch.
Before running the script, you must provide your Google Gemini API key.
-
Create a new file named
.envin the root of the project directory. -
Add your API key to this file:
GEMINI_API_KEY="your_actual_api_key_goes_here"
This bot is hard-coded to work with a specific Google Form.
If you want to run this bot on your own survey, you will need to:
-
Update
config.py: Change theFORM_URLto your new form's URL. You should also update thePROMPTSandRATINGSvariables to match the questions on your form. -
Modify
bot.py: This is the most important step. You must openbot.pyand change theBy.XPATHstrings in therun()method to match the elements on your new form. You will need to inspect your form's HTML to find the correctaria-label,data-value, or text for each element.
With your virtual environment active and your .env file in place, simply run main.py:
python main.py
Specify how many times you want the script to run by changing num_runs in 'main.py'.