Advertisement
asweigart

formfiller.py

Jun 27th, 2019
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. import pyautogui
  2. import time
  3. import csv
  4.  
  5. # Read in the data from the csv file.
  6. with open('C:\\Users\\Al\\Desktop\\colors.csv') as colorsFile:
  7. csvReader = csv.reader(colorsFile)
  8. colorsList = list(csvReader)
  9.  
  10. # Give the user a few seconds to set up the browser.
  11. print('The program starts in 5 seconds. Make sure the form is loaded and the browser window is maximized.')
  12. time.sleep(5)
  13.  
  14. for row in colorsList:
  15. name = row[0]
  16. color = row[1]
  17.  
  18. # Click on the "Name" field.
  19. pyautogui.click(888, 658) # NOTE: These XY coordinates will be different on your computer.
  20.  
  21. # Type the "Name" info.
  22. pyautogui.write(name)
  23.  
  24. # Click on "Color" field.
  25. pyautogui.click(886, 841)
  26.  
  27. # Type the "Color" info.
  28. pyautogui.write(color)
  29.  
  30. break # Comment this line out when you've finished the dry run.
  31.  
  32. # Click the submit button.
  33. pyautogui.click(907, 992)
  34.  
  35. # Wait for the form to submit.
  36. time.sleep(3)
  37.  
  38. # Click on "submit another response"
  39. pyautogui.click(887, 612)
  40.  
  41. # Wait for the page to load.
  42. time.sleep(3)
  43.  
  44. print('Info entered: ' + name + ' ' + color)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement