-
Notifications
You must be signed in to change notification settings - Fork 0
/
covid19.py
65 lines (58 loc) · 2.73 KB
/
covid19.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
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from datetime import date
from PIL import Image
import time
today = date.today()
currDateFormatted = today.strftime("%d-%m-%Y")
PATH = 'C:\webdrivers\chromedriver.exe'
driver = Chrome(PATH)
driver.implicitly_wait(15)
driver.get('https://crmitcsmportal.force.com/CRMITSolutionsCOVID19/s/signin-page')
currentWindow = driver.current_window_handle
time.sleep(10)
print('After Sleep')
emailId = 'EMAIL_ID' #your email id
pwd = 'PWD' #your password
selectedIframe = driver.find_element(By.XPATH, '//iframe')
idforIframe = selectedIframe.get_attribute("id")
print('Iframe ID: ', idforIframe)
driver.switch_to.frame(idforIframe)
text_file = open("PageSource.txt", "w")
text_file.truncate(0)
n = text_file.write(driver.page_source)
text_file.close()
print(n)
driver.find_element(By.NAME, 'j_id0:frm:selectrecord').click()
driver.find_element(By.NAME, 'j_id0:frm:selectrecord1').click()
driver.find_element(By.CLASS_NAME, 'abcRioButtonContentWrapper').click()
for handle in driver.window_handles:
if handle != currentWindow:
login_page = handle
driver.switch_to.window(login_page)
print('Switched')
time.sleep(10)
enterMail = driver.find_element(By.XPATH, '//*[@id="identifierId"]')
enterMail.send_keys(emailId)
driver.find_element(By.XPATH, '//*[@id="identifierNext"]/div/button').click()
time.sleep(10)
pwdBox = driver.find_element(By.XPATH, '//*[@id="password"]/div[1]/div/div[1]/input')
pwdBox.send_keys(pwd)
driver.find_element(By.XPATH, '//*[@id="passwordNext"]/div/button').click()
time.sleep(10)
driver.switch_to.window(currentWindow)
selectedIframe = driver.find_element(By.XPATH, '//iframe')
idforIframe = selectedIframe.get_attribute("id")
print('Iframe ID: ', idforIframe)
driver.switch_to.frame(idforIframe)
driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div[2]/div/div/article/table/tbody/tr[1]/td[4]/div/lightning-input/div/span/label/span[1]').click()
driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div[2]/div/div/article/table/tbody/tr[2]/td[4]/div/lightning-input/div/span/label/span[1]').click()
driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div[2]/div/div/article/table/tbody/tr[3]/td[4]/div/lightning-input/div/span/label/span[1]').click()
driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div[2]/div/div/article/table/tbody/tr[4]/td[4]/div/lightning-input/div/span/label/span[1]').click()
driver.find_element(By.XPATH, '/html/body/div[3]/div[2]/div/div[2]/div/div/article/div[3]/button').click()
time.sleep(8)
driver.save_screenshot('act_'+currDateFormatted+'.png')
screenshot = Image.open('act_'+currDateFormatted+'.png')
screenshot.show()
driver.quit()
print('Logged')