-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautofill.py
56 lines (47 loc) · 1.58 KB
/
autofill.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
from pprint import pprint
from sys import exit
from datetime import datetime,timedelta,date
import mysql.connector
import random
##Global Variables
#mysql config
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="autofill_greatech_covid"
)
#team_json
team = None
def auto_fill():
driver.get("https://rocky-plains-03473.herokuapp.com/")
#click button
driver.find_element_by_xpath('/html/body/div/div/div[2]/div/a[2]/button').click()
#temperature range random
temp = round(random.uniform(36.3, 36.6),1)
driver.find_element_by_xpath('/html/body/div/div/form/div[1]/input').send_keys("201545")
driver.find_element_by_xpath('/html/body/div/div/form/div[2]/input').send_keys(str(temp))
driver.find_element_by_xpath('/html/body/div/div/form/div[3]/div[1]/label').click()
driver.find_element_by_xpath('/html/body/div/div/form/div[5]/div/button').click()
time.sleep(10)
#driver.save_screenshot("screenshot.png")
#time.sleep(10)
def get_team_details():
try:
mycursor = mydb.cursor(dictionary=True)
sql = "SELECT * FROM employee WHERE activate = 1"
val = ()
mycursor.execute(sql,val)
return mycursor.fetchall()
except Exception as error:
print(error)
team = get_team_details()
print(team[0]['name'])
#init_chrome_driver
PATH = "path-for-chrome-driver"
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
driver = webdriver.Chrome(PATH,options=options)