-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathautomate_csv.py
40 lines (28 loc) · 1.38 KB
/
automate_csv.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#-------------------------------------------------------------------------------
# Imports
import csv
import requests
from selenium import webdriver
import time
#-------------------------------------------------------------------------------
# Setup
name = 0
age = 1
score = 2
with open('data.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
#-------------------------------------------------------------------------------
# Web Automation
for line in csv_reader:
driver = webdriver.Chrome()
driver.get('https://docs.google.com/forms/d/e/1FAIpQLSfFjWpXF8JgnPqQHkzRDDmHJgJB-nkRmfvS4Txvt2ppaO3VJg/viewform')
time.sleep(2)
name_field = driver.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[2]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/input')
name_field.send_keys(line[0])
age_field = driver.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[2]/div[2]/div/div/div[2]/div/div[1]/div/div[1]/input')
age_field.send_keys(line[1])
score_field = driver.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[2]/div[3]/div/div/div[2]/div/div[1]/div/div[1]/input')
score_field.send_keys(line[2])
submit = driver.find_element_by_xpath('//*[@id="mG61Hd"]/div[2]/div/div[3]/div[1]/div/div/span/span')
submit.click()
#-------------------------------------------------------------------------------