Skip to content

Commit 1808edc

Browse files
Merge pull request #546 from Brain-up/issue_189
Issue_189_SPECIALISTS_PAGE_tests
2 parents fe1f316 + c3a631a commit 1808edc

File tree

1 file changed

+6
-44
lines changed

1 file changed

+6
-44
lines changed

pages/specialists_page.py

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Methods for verifying web elements on the 'Specialists' page"""
2-
import time
32
import allure
43
import requests
4+
from selenium.webdriver.support.wait import WebDriverWait as Wait
5+
from selenium.common import TimeoutException
56
from pages.base_page import BasePage
67
from test_data.links import MainPageLinks
78
from locators.specialists_page_locators import SpecialistsPageLocators
89
from locators.start_unauthorized_page_locators import StartUnauthorizedPageLocators
9-
from selenium.common import TimeoutException
1010

1111

1212
class SpecialistsPage(BasePage):
@@ -39,7 +39,6 @@ def check_elements_visibility_on_1st_level_on_page(self):
3939
@allure.step("Get structure of the 2nd level of nesting on the page")
4040
def get_structure_of_2nd_level(self):
4141
elements = self.elements_are_present(self.locators.PAGE_SECOND_LEVEL_ELEMENTS)
42-
# tags = [element.tag_name for element in elements]
4342
return elements
4443

4544
@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):
4948
@allure.step("Get structure of the 3rd level of nesting on the page")
5049
def get_structure_of_3rd_level(self):
5150
elements = self.elements_are_present(self.locators.PAGE_THIRD_LEVEL_ELEMENTS)
52-
# tags = [element.tag_name for element in elements]
5351
return elements
5452

5553
@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):
5957
@allure.step("Get structure of the 4th level of nesting on the page")
6058
def get_structure_of_4th_level(self):
6159
elements = self.elements_are_present(self.locators.PAGE_FOURTH_LEVEL_ELEMENTS)
62-
# tags = [element.tag_name for element in elements]
6360
return elements
6461

6562
@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):
6966
@allure.step("Get structure of the 5th level of nesting on the page")
7067
def get_structure_of_5th_level(self):
7168
elements = self.elements_are_present(self.locators.PAGE_FIFTH_LEVEL_ELEMENTS)
72-
# tags = [element.tag_name for element in elements]
7369
return elements
7470

7571
@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):
7975
@allure.step("Get structure of the 6th level of nesting on the page")
8076
def get_structure_of_6th_level(self):
8177
elements = self.elements_are_present(self.locators.PAGE_SIXTH_LEVEL_ELEMENTS)
82-
# tags = [element.tag_name for element in elements]
8378
return elements
8479

8580
@allure.step("Check if elements of the 6th level of nesting are visible")
@@ -132,13 +127,13 @@ def get_list_of_card_images(self):
132127

133128
@allure.step("Check the image in each specialist card is visible")
134129
def check_image_visibility_in_cards(self):
135-
time.sleep(5)
136130
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
139134
except TimeoutException:
140135
print("The entire set of images has not been loaded during the allotted time")
141-
return None
136+
return False
142137

143138
@allure.step("Get the list of names in specialist cards on the 5th level of nesting on the page")
144139
def get_list_of_names_in_cards(self):
@@ -217,39 +212,6 @@ def get_images_alt(self):
217212
def get_images_sizes(self):
218213
return [image.size for image in self.get_list_of_card_images()]
219214

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-
253215
@allure.step("Check changes of images sizes after resizing")
254216
def check_size_changes_of_images(self):
255217
images = self.get_list_of_card_images()

0 commit comments

Comments
 (0)