Skip to content

Issue_189_SPECIALISTS_PAGE_tests #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 6 additions & 44 deletions pages/specialists_page.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Methods for verifying web elements on the 'Specialists' page"""
import time
import allure
import requests
from selenium.webdriver.support.wait import WebDriverWait as Wait
from selenium.common import TimeoutException
from pages.base_page import BasePage
from test_data.links import MainPageLinks
from locators.specialists_page_locators import SpecialistsPageLocators
from locators.start_unauthorized_page_locators import StartUnauthorizedPageLocators
from selenium.common import TimeoutException


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

@allure.step("Check if elements of the 2nd level of nesting are visible")
Expand All @@ -49,7 +48,6 @@ def check_elements_visibility_on_2nd_level_on_page(self):
@allure.step("Get structure of the 3rd level of nesting on the page")
def get_structure_of_3rd_level(self):
elements = self.elements_are_present(self.locators.PAGE_THIRD_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 3rd level of nesting are visible")
Expand All @@ -59,7 +57,6 @@ def check_elements_visibility_on_3rd_level_on_page(self):
@allure.step("Get structure of the 4th level of nesting on the page")
def get_structure_of_4th_level(self):
elements = self.elements_are_present(self.locators.PAGE_FOURTH_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 4th level of nesting are visible")
Expand All @@ -69,7 +66,6 @@ def check_elements_visibility_on_4th_level_on_page(self):
@allure.step("Get structure of the 5th level of nesting on the page")
def get_structure_of_5th_level(self):
elements = self.elements_are_present(self.locators.PAGE_FIFTH_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

@allure.step("Check if elements of the 5th level of nesting are visible")
Expand All @@ -79,7 +75,6 @@ def check_elements_visibility_on_5th_level_on_page(self):
@allure.step("Get structure of the 6th level of nesting on the page")
def get_structure_of_6th_level(self):
elements = self.elements_are_present(self.locators.PAGE_SIXTH_LEVEL_ELEMENTS)
# tags = [element.tag_name for element in elements]
return elements

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

@allure.step("Check the image in each specialist card is visible")
def check_image_visibility_in_cards(self):
time.sleep(5)
try:
card_images_visibility = all(element.is_displayed() for element in self.get_list_of_card_images())
return card_images_visibility
Wait(self.driver, 10).until(
lambda driver: all(element.is_displayed() for element in self.get_list_of_card_images()))
return True
except TimeoutException:
print("The entire set of images has not been loaded during the allotted time")
return None
return False

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

@allure.step("Check changes of images sizes after resizing")
def check_size_changes_of_images1(self):
images = self.get_list_of_card_images()
images_sizes_before = [image.size for image in images]
# self.driver.set_window_size(1200, 800)
self.driver.set_window_size(220, 700)
images_sizes_after = [image.size for image in images]
changed, lost, unchanged = [], [], []
for i in range(len(images)):
changed.append(i) if images_sizes_before[i] != images_sizes_after[i] else unchanged.append(i)
lost.append(i) if images_sizes_after[i] == {'height': 0, 'width': 0} else None
# print('All images have changed sizes' if len(changed) == len(images) else 'Not all images have changed sizes')
return changed

@allure.step("Check changes of images sizes after resizing")
def check_size_changes_of_images2(self):
time.sleep(3)
images = self.get_list_of_card_images()
images_sizes_before = [image.size for image in images]
self.driver.set_window_size(400, 1080)
time.sleep(7)
try:
images_sizes_after = [image.size for image in images]
changed, lost, unchanged = [], [], []
for i in range(len(images)):
changed.append(i) if images_sizes_before[i] != images_sizes_after[i] else unchanged.append(i)
lost.append(i) if images_sizes_after[i] == {'height': 0, 'width': 0} else None
print(f'All images have changed sizes' if len(changed) == len(images)
else f'Images {unchanged} have unchanged sizes')
return changed
except TimeoutException:
print("The entire set of images has not been loaded during the allotted time after resizing")

@allure.step("Check changes of images sizes after resizing")
def check_size_changes_of_images(self):
images = self.get_list_of_card_images()
Expand Down
Loading