-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
73 lines (55 loc) · 2.3 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from ImgCompare import compare, show
import time
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
import playsound
from TextExtract import crop,textExtract
firefox_browser = webdriver.Firefox(executable_path=r'C:\Program Files\gecko\geckodriver.exe')
def runResultCheck():
firefox_browser.get("http://results.drait.in/")
time.sleep(2)
print("Opening firefox")
login_form = firefox_browser.find_element_by_xpath("//*[contains(text(), 'Student')]").click()
time.sleep(6)
delay = 80
try:
myElem = WebDriverWait(firefox_browser, delay).until(EC.presence_of_element_located((By.ID, 'ugpg')))
print("Page is ready!")
select = Select(firefox_browser.find_element_by_id('ugpg'))
select.select_by_visible_text('UG-SEE')
usn = firefox_browser.find_element_by_css_selector("#usn")
submitButton = firefox_browser.find_element_by_css_selector("#submit")
enterText = firefox_browser.find_element_by_css_selector("#captcha")
text=textExtract()
usn.send_keys("1DA17IS0xx")
enterText.send_keys(text)
firefox_browser.get_screenshot_as_file(r"C:\Users\V Sangarya\Desktop\ResultsHomePage.png")
submitButton.send_keys(Keys.ENTER)
show()
except TimeoutException:
print ("Loading took too much time!")
runResultCheck()
delay = 180
try:
myElem = WebDriverWait(firefox_browser, delay).until(EC.presence_of_element_located((By.ID, 'tableData')))
print ("Page is ready!")
firefox_browser.get_screenshot_as_file(r"C:\Users\V Sangarya\Desktop\screenshot.png")
except TimeoutException:
print ("Loading took too much time!")
runResultCheck()
print("Done")
x=compare()
if(x==1.0):
print("Results not out")
print(x)
runResultCheck()
else:
print("Results out")
print(x)
playsound.playsound(r'C:\Users\V Sangarya\Downloads\AlertSound.mp3', True)
runResultCheck()