-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_personal_area.py
113 lines (87 loc) · 4.72 KB
/
test_personal_area.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import time
import unittest
from log_in import log_in
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from driver_set_up import driver_set_up
class Testcase(unittest.TestCase):
def setUp(self):
self.driver = driver_set_up()
self.driver.get('http://qa.trado.ai/')
log_in(self.driver)
go_to_pa = WebDriverWait(self.driver, 10).until((EC.element_to_be_clickable((By.XPATH, "//*[@id='root']/div/div[2]/header/div/div/div[1]/a"))))
go_to_pa.click()
def test_delivery_details(self):
"""
a test for the delivery details of the user
:return:
"""
name = "Moshe"
last_name = "levi"
edit = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[3]/form/div[4]')))
edit.click()
time.sleep(2)
first_name_element = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[3]/form/div[1]/div[1]/span/input')))
first_name_element.click()
first_name_element.clear()
first_name_element.send_keys(name)
time.sleep(2)
last_name_element = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[3]/form/div[1]/div[2]/span/input')))
last_name_element.click()
last_name_element.clear()
last_name_element.send_keys(last_name)
email_element = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[3]/form/div[1]/div[4]/span/input')))
email_element.click()
email_element.clear()
email_element.send_keys("moshe123@gmail.com")
time.sleep(2)
city_and_street = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[3]/form/div[2]/div/div[1]/div[1]/input')))
city_and_street.click()
city_and_street.clear()
city_and_street.send_keys("city/st")
time.sleep(2)
street_num = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[3]/form/div[2]/div/div[1]/div[2]/span/input')))
street_num.click()
street_num.clear()
street_num.send_keys("8")
time.sleep(2)
zip_code = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[3]/form/div[2]/div/div[1]/div[3]/span/input')))
zip_code.click()
zip_code.send_keys("81234132")
save_details_btn = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.CLASS_NAME, 'form_editModeSubmitBtn')))
save_details_btn.click()
user_name = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/header/div/div/div[1]/a'))).text
assert user_name == f'שלום {name} {last_name}'
def test_my_wallet(self):
"""
testing withdrawal from the E-Wallet
:return:
"""
withdraw_btn = WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div[1]/section/button')))
withdraw_btn.click()
try:
WebDriverWait(self.driver, 10).until_not(EC.presence_of_element_located((By.XPATH, '//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div[1]/section/button')))
assert True
except TimeoutException:
assert False
def test_contact_us_navigation(self):
contact_us_btns = [
'//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div[2]/div[3]/span/a/label',
'//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div[4]/div[3]/span/a/label',
'//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div[3]/div[3]/span/a/label',
'//*[@id="root"]/div/div[2]/div[2]/div/div[2]/div[1]/div[2]/span/a/label'
]
wait = WebDriverWait(self.driver, 10)
for btn in contact_us_btns:
try:
element = wait.until(EC.element_to_be_clickable((By.XPATH, btn)))
element.click()
print(f"Clicked on element: {btn}")
# Perform some checks or actions on the new page if needed
except TimeoutException:
print(f"Element {btn} not found or not clickable within the specified time.")
# Navigate back to the main page after each click
self.driver.back()
assert True