forked from birolemekli/tcdd-bilet-yer-kontrol
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRota.py
54 lines (45 loc) · 2.18 KB
/
Rota.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
"""
@author: Birol Emekli
"""
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import UnexpectedAlertPresentException
import time
class Rota:
def __init__(self,driver,nereden,nereye,date):
self.driver=driver
self.first_location=nereden
self.last_location=nereye
self.date=date
def dataInput(self):
try:
text1 = self.driver.find_element(By.CSS_SELECTOR ,"#nereden")
text1.clear()
text1.send_keys(self.first_location)
print('Nereden: ' + self.first_location)
time.sleep(0.5)
element = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/ul[1]/li/a")))
ActionChains(self.driver).move_to_element(element).perform()
element.click()
text2 = self.driver.find_element(By.CSS_SELECTOR ,"#nereye")
text2.clear()
text2.send_keys(self.last_location)
print('Nereye: ' + self.last_location)
time.sleep(0.5)
element = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/ul[2]/li/a")))
ActionChains(self.driver).move_to_element(element).perform()
element.click()
time.sleep(0.5)
date = self.driver.find_element(By.CSS_SELECTOR ,"#trCalGid_input")
date.clear()
date.send_keys(self.date)
print('Tarih: '+self.date)
time.sleep(0.5)
button = WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located((By.XPATH, "/html/body/div[3]/div[2]/div/div[2]/ul/li[1]/div/form/div[3]/p[3]/button/span")))
self.driver.execute_script("arguments[0].click();", button)
except:
print ("Güzergah bilgilerinde hata meydana geldi. Kontrol ederek tekrar deneyiniz. İstasyonları doğru girdiğinizden emin olunuz")
self.driver.quit()
exit()