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.7.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distributions

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

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

Uploaded Python 3

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

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for python_selenium_google_form-0.7.0.tar.gz
Algorithm Hash digest
SHA256 cca58f696d88c6b09f5eba6db36d2ee12e08b0c672f47eb515cda4f87b70fdb0
MD5 5b42d62c20c086f423c14a8967179052
BLAKE2b-256 1687ebf5786d5f99283f9359b28b79c7db5a9201de79bceb3f86f20d2b5c3224

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_selenium_google_form-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1018e73aa901671d1f11fff1d6ec8a0a3287bfbc7ebafce0990ebd288ec74360
MD5 bfe78c45fa276c9a522e36fbbc761cd9
BLAKE2b-256 584277725bdcfcbee6ead42712966b3d2a3faf5b4597598692acf959b1f07cb3

See more details on using hashes here.

File details

Details for the file python_selenium_google_form-0.7.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for python_selenium_google_form-0.7.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 92d5ae6c08e63fe88a0ade9f3cba79379e7b0cc9b3a362c5dbbab0e212c64077
MD5 e0091e4382a839cc621bb0e804666e47
BLAKE2b-256 8bd76637d9c21e8ca575564d64c11ce067714a8f008b240841e47cd9934c85ca

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