-
Notifications
You must be signed in to change notification settings - Fork 0
/
TS06_Body_section_Cum_poti_ajuta_tu.py
126 lines (98 loc) · 3.92 KB
/
TS06_Body_section_Cum_poti_ajuta_tu.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from selenium.webdriver import Chrome
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
# TC 01 - Testing the functionality of the search bar by typing inside it
def searching_bar():
# Initialize the browser
browser = Chrome()
browser.get("https://oportunitatisicariere.ro/")
browser.maximize_window()
time.sleep(1)
# Locate and interact with "Cum poti ajuta tu" section
link = browser.find_element(By.LINK_TEXT, 'Cum poți ajuta tu?')
link.click()
time.sleep(2)
# Scroll to the job section
browser.execute_script(
"document.getElementsByClassName('how-contribute__jobs swiper swiper-initialized swiper-horizontal')[0].scrollIntoView()")
time.sleep(3)
# TC 02 - Left arrow is functional:
arrowL = browser.find_element(By.ID, "arrow-left")
arrowL.click()
time.sleep(2)
arrowL.click()
time.sleep(2)
arrowL.click()
time.sleep(2)
# TC 03 - Right arrow is functional:
arrowR = browser.find_element(By.ID, "arrow-right")
action_chains = ActionChains(browser)
action_chains.double_click(arrowR).perform()
time.sleep(2)
action_chains.double_click(arrowR).perform()
time.sleep(2)
action_chains.double_click(arrowR).perform()
time.sleep(3)
# Locate the search bar
search = browser.find_element(By.XPATH, '//input[@class="search-input"]')
# TC 04 - List of words to write in the searching bar:
words = ['tester', 'hr', 'marketing', 'UX', 'Developer', "Assistant manager", "not found", "Onboarding project"]
for word in words:
search.clear() # Clear the input field before entering a new word
search.send_keys(word)
time.sleep(2) # Wait for the results to load
search.send_keys(Keys.ENTER) # Press Enter after typing the word
time.sleep(3) # Wait to see the cleared state before the next iteration
# TC05 -On page of "Onboarding project volunteer" the button "detalii" is functional:
detalii_button = browser.find_element(By.XPATH, '//a[@class = "detail-btn"]')
detalii_button.click()
time.sleep(3)
# Switch to the new window that opened
original_window = browser.current_window_handle
all_windows = browser.window_handles
# Assume the new window is the last one opened
for window in all_windows:
if window != original_window:
browser.switch_to.window(window)
break
#Interract with the new window:
prev_height = -1
max_scrolls = 100
scroll_count = 0
#Scrolling down and up the new window
while scroll_count < max_scrolls:
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(2) # give some time for new results to load
new_height = browser.execute_script("return document.body.scrollHeight")
if new_height == prev_height:
break
prev_height = new_height
scroll_count += 1
time.sleep(2)
browser.execute_script("window.scrollTo(0, 0)")
time.sleep(2)
# TC 06 - "Aplica" button is functional
apply_button = browser.find_element(By.CLASS_NAME, "applyBtn")
action_chains = ActionChains(browser)
action_chains.double_click(apply_button).perform()
# Switch to the new window that opened
original_window = browser.current_window_handle
all_windows = browser.window_handles
# Assume the new window is the last one opened
for window in all_windows:
if window != original_window:
browser.switch_to.window(window)
break
time.sleep(6)
browser.close()
browser.switch_to.window(original_window)
time.sleep(2)
#TC 07 - verifying the functionality of the link "Inapoi la locurile de munca":
link_up = browser.find_element(By.CLASS_NAME,"backTxt")
link_up.click()
time.sleep(2)
# Close the browser
browser.quit()
searching_bar()