Automatically filling multiple responses into a Google Form with Selenium and Python
Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e. Python, Java, C#, etc.. we will be working with Python. Selenium Tutorial covers all topics such as– WebDriver, WebElement, Unit Testing with selenium.
The Task here is to fill multiple responses with the same Google form using selenium in python. Link to the Google form used in this example is given below:
Form link – Click Here
The form has five entries:
- Phone Number
Name, Email & Phone Number has same class name quantumWizTextinputPaperinputInput and Address & Comments has same class name quantumWizTextinputPapertextareaInput. Data is in the form of a list.
The given program also uses count, reason being textboxes contain a list, whose class name is “quantumWizTextinputPaperinputInput” and textareaboxes contain a list, whose class name is “quantumWizTextinputPapertextareaInput” and when these two classes are added it results in a list. The data is also provided in a form of a list, thus count variable will be incremented with each data variable.
# values of data
[name, email, phone number, address, comments]
datas = [
[‘Mary D Joiner’,’MaryDJoiner@gmail.com’,’4079025063′,’2474 McDonald Avenue,Maitland’,’NA’],
[‘Karen B Johnson’,’KarenBJohnson@gmail.com’,’3153437575′,’2143 Oak Street,GRAND ISLE’,’NA’],
To achieve our required functionality given steps needs to followed in a perfect order:
- Import selenium and time module
- Add chrome driver path and Form URL
- Add some delay, until page gets fully loaded
- Add data in the form of list
- Iterate through each data and fill detail
- Close the window
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course