1
1
"""Methods for verifying web elements on the 'Specialists' page"""
2
- import time
3
2
import allure
4
3
import requests
4
+ from selenium .webdriver .support .wait import WebDriverWait as Wait
5
+ from selenium .common import TimeoutException
5
6
from pages .base_page import BasePage
6
7
from test_data .links import MainPageLinks
7
8
from locators .specialists_page_locators import SpecialistsPageLocators
8
9
from locators .start_unauthorized_page_locators import StartUnauthorizedPageLocators
9
- from selenium .common import TimeoutException
10
10
11
11
12
12
class SpecialistsPage (BasePage ):
@@ -39,7 +39,6 @@ def check_elements_visibility_on_1st_level_on_page(self):
39
39
@allure .step ("Get structure of the 2nd level of nesting on the page" )
40
40
def get_structure_of_2nd_level (self ):
41
41
elements = self .elements_are_present (self .locators .PAGE_SECOND_LEVEL_ELEMENTS )
42
- # tags = [element.tag_name for element in elements]
43
42
return elements
44
43
45
44
@allure .step ("Check if elements of the 2nd level of nesting are visible" )
@@ -49,7 +48,6 @@ def check_elements_visibility_on_2nd_level_on_page(self):
49
48
@allure .step ("Get structure of the 3rd level of nesting on the page" )
50
49
def get_structure_of_3rd_level (self ):
51
50
elements = self .elements_are_present (self .locators .PAGE_THIRD_LEVEL_ELEMENTS )
52
- # tags = [element.tag_name for element in elements]
53
51
return elements
54
52
55
53
@allure .step ("Check if elements of the 3rd level of nesting are visible" )
@@ -59,7 +57,6 @@ def check_elements_visibility_on_3rd_level_on_page(self):
59
57
@allure .step ("Get structure of the 4th level of nesting on the page" )
60
58
def get_structure_of_4th_level (self ):
61
59
elements = self .elements_are_present (self .locators .PAGE_FOURTH_LEVEL_ELEMENTS )
62
- # tags = [element.tag_name for element in elements]
63
60
return elements
64
61
65
62
@allure .step ("Check if elements of the 4th level of nesting are visible" )
@@ -69,7 +66,6 @@ def check_elements_visibility_on_4th_level_on_page(self):
69
66
@allure .step ("Get structure of the 5th level of nesting on the page" )
70
67
def get_structure_of_5th_level (self ):
71
68
elements = self .elements_are_present (self .locators .PAGE_FIFTH_LEVEL_ELEMENTS )
72
- # tags = [element.tag_name for element in elements]
73
69
return elements
74
70
75
71
@allure .step ("Check if elements of the 5th level of nesting are visible" )
@@ -79,7 +75,6 @@ def check_elements_visibility_on_5th_level_on_page(self):
79
75
@allure .step ("Get structure of the 6th level of nesting on the page" )
80
76
def get_structure_of_6th_level (self ):
81
77
elements = self .elements_are_present (self .locators .PAGE_SIXTH_LEVEL_ELEMENTS )
82
- # tags = [element.tag_name for element in elements]
83
78
return elements
84
79
85
80
@allure .step ("Check if elements of the 6th level of nesting are visible" )
@@ -132,13 +127,13 @@ def get_list_of_card_images(self):
132
127
133
128
@allure .step ("Check the image in each specialist card is visible" )
134
129
def check_image_visibility_in_cards (self ):
135
- time .sleep (5 )
136
130
try :
137
- card_images_visibility = all (element .is_displayed () for element in self .get_list_of_card_images ())
138
- return card_images_visibility
131
+ Wait (self .driver , 10 ).until (
132
+ lambda driver : all (element .is_displayed () for element in self .get_list_of_card_images ()))
133
+ return True
139
134
except TimeoutException :
140
135
print ("The entire set of images has not been loaded during the allotted time" )
141
- return None
136
+ return False
142
137
143
138
@allure .step ("Get the list of names in specialist cards on the 5th level of nesting on the page" )
144
139
def get_list_of_names_in_cards (self ):
@@ -217,39 +212,6 @@ def get_images_alt(self):
217
212
def get_images_sizes (self ):
218
213
return [image .size for image in self .get_list_of_card_images ()]
219
214
220
- @allure .step ("Check changes of images sizes after resizing" )
221
- def check_size_changes_of_images1 (self ):
222
- images = self .get_list_of_card_images ()
223
- images_sizes_before = [image .size for image in images ]
224
- # self.driver.set_window_size(1200, 800)
225
- self .driver .set_window_size (220 , 700 )
226
- images_sizes_after = [image .size for image in images ]
227
- changed , lost , unchanged = [], [], []
228
- for i in range (len (images )):
229
- changed .append (i ) if images_sizes_before [i ] != images_sizes_after [i ] else unchanged .append (i )
230
- lost .append (i ) if images_sizes_after [i ] == {'height' : 0 , 'width' : 0 } else None
231
- # print('All images have changed sizes' if len(changed) == len(images) else 'Not all images have changed sizes')
232
- return changed
233
-
234
- @allure .step ("Check changes of images sizes after resizing" )
235
- def check_size_changes_of_images2 (self ):
236
- time .sleep (3 )
237
- images = self .get_list_of_card_images ()
238
- images_sizes_before = [image .size for image in images ]
239
- self .driver .set_window_size (400 , 1080 )
240
- time .sleep (7 )
241
- try :
242
- images_sizes_after = [image .size for image in images ]
243
- changed , lost , unchanged = [], [], []
244
- for i in range (len (images )):
245
- changed .append (i ) if images_sizes_before [i ] != images_sizes_after [i ] else unchanged .append (i )
246
- lost .append (i ) if images_sizes_after [i ] == {'height' : 0 , 'width' : 0 } else None
247
- print (f'All images have changed sizes' if len (changed ) == len (images )
248
- else f'Images { unchanged } have unchanged sizes' )
249
- return changed
250
- except TimeoutException :
251
- print ("The entire set of images has not been loaded during the allotted time after resizing" )
252
-
253
215
@allure .step ("Check changes of images sizes after resizing" )
254
216
def check_size_changes_of_images (self ):
255
217
images = self .get_list_of_card_images ()
0 commit comments