asweigart Jun 27th, 2019 (edited) 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- import pyautogui
- import time
- import csv
- # Read in the data from the csv file.
- with open('C:\\Users\\Al\\Desktop\\colors.csv') as colorsFile:
- csvReader = csv.reader(colorsFile)
- colorsList = list(csvReader)
- # Give the user a few seconds to set up the browser.
- print('The program starts in 5 seconds. Make sure the form is loaded and the browser window is maximized.')
- for row in colorsList:
- name = row
- color = row
- # Click on the "Name" field.
- pyautogui.click(888, 658) # NOTE: These XY coordinates will be different on your computer.
- # Type the "Name" info.
- # Click on "Color" field.
- pyautogui.click(886, 841)
- # Type the "Color" info.
- break # Comment this line out when you've finished the dry run.
- # Click the submit button.
- pyautogui.click(907, 992)
- # Wait for the form to submit.
- # Click on "submit another response"
- pyautogui.click(887, 612)
- # Wait for the page to load.
- print('Info entered: ' + name + ' ' + color)
RAW Paste Data