Skip to main content

Automate Google Forms

Project description

Introduction

The Python Selenium Google Form package is used to automate the completion of Google Forms. This package uses the Google Chrome browser.

Installing

If you have pip on your system, you can simply install or upgrade the Python bindings:

    pip install python-selenium-google-form

Alternately, you can download the source distribution from PyPI https://pypi.org/project/python-selenium-google-form/#files, unarchive it, and run:

    python setup.py install

Using

To use this package you should create Selenium driver and navigate to target Google Form. You can do it like me. I have 2 useful functions to simplify it:

import undetected_chromedriver as uc

def get_driver(options: list) -> uc.Chrome:
    """
    Creating driver with settings
    :param options: uc.ChromeOptions
    :return: uc.Chrome
    """

    if options:
        driver_options: uc.ChromeOptions = uc.ChromeOptions()

        for option in options:
            driver_options.add_argument(option)

        return uc.Chrome(options=driver_options)

    else:
        return uc.Chrome()


def get_page(url: str, driver: uc.Chrome) -> None:
    """
    Loading page
    :param url: str
    :param driver: uc.Chrome
    :return: None
    """

    driver.get(url)

Using these functions and current package you can automate the completion of Google Forms. For example:

from time import sleep
from typing import List

from python_selenium_google_form import process_form_fields_with_hotkeys, FieldConfig, FieldType

from selenium_methods import get_driver, get_page

WEB_DRIVER_OPTIONS = ["--start-maximized", "--disable-popup-blocking"]


def main() -> None:
    driver = get_driver(WEB_DRIVER_OPTIONS)
    driver.implicitly_wait(10)

    get_page(
        "https://docs.google.com/forms/d/e/1FAIpQLSfP0lcoj1XrdXtKCSwSkCaPEgGaGkY267U6yLCH3WkIz-58vg/viewform",
        driver)

    fields_list: List[FieldConfig] = [
        FieldConfig("first_name", FieldType.TEXT, "John"),
        FieldConfig("last_name", FieldType.TEXT, "Doe"),
        FieldConfig("job_title", FieldType.TEXT, "Software Developer"),
        FieldConfig("education_level", FieldType.RADIO, [1, 0, 0]),  # 1 means that field is selected, 0 - not selected
        FieldConfig("favourite_subjects", FieldType.CHECKBOX, [0, 0, 1, 1, 0]),  # 1 means that field is selected, 0 - not selected
        FieldConfig("experience", FieldType.SELECT, [0, 0, 1, 0]),  # 1 means that field is selected, 0 - not selected
        FieldConfig("date", FieldType.DATE, "01-09-2022"),
    ]

    process_form_fields_with_hotkeys(fields_list, driver)

    sleep(10)


main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_selenium_google_form-0.6.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_selenium_google_form-0.6.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file python_selenium_google_form-0.6.0.tar.gz.

File metadata

File hashes

Hashes for python_selenium_google_form-0.6.0.tar.gz
Algorithm Hash digest
SHA256 daf6331cec062d9a17cfea953cede4a16c57f58c80cb28a040109633ef9ebe37
MD5 e4c1ce16a8eb935ee592388a81f7d93b
BLAKE2b-256 5c54265b7809f79016110f036c853c8f14119840b7613134dfe68c15e9e548ca

See more details on using hashes here.

File details

Details for the file python_selenium_google_form-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_selenium_google_form-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 263337286a674cc2a80240b6f37312d71b40963565a8b55cf7f426b82f2fccd7
MD5 a2fd115b91342ca7bdcbef48d1510b13
BLAKE2b-256 9057e390c0c139fd85f96bfffb7c60ee473b1e56241857a54e310cb5dd3674dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page