class PagesHeaderTests(BaseTestClass): web = web_reader.load() logo_xpath = HeaderLocators.logo_xpath homepage_button_xpath = HeaderLocators.homepage_button_xpath our_candles_button_xpath = HeaderLocators.our_candles_button_xpath make_candle_button_xpath = HeaderLocators.make_candle_button_xpath where_to_buy_button_xpath = HeaderLocators.where_to_buy_button_xpath faq_button_xpath = HeaderLocators.faq_button_xpath contact_button_xpath = HeaderLocators.contact_button_xpath @screenshot def test_correct_page_redirection_after_logo_click(self): expected_text = self.web["main_page_title"] self.home_page.visit() self.click_button(self.logo_xpath) self.assert_page_title(self.driver.current_url, expected_text) @screenshot def test_correct_page_redirection_after_menu_button_click(self): data = {self.web["en_homepage_title"]: self.homepage_button_xpath, self.web["our_candles_title"]: self.our_candles_button_xpath, self.web["make_candle_title"]: self.make_candle_button_xpath, self.web["where_to_buy_title"]: self.where_to_buy_button_xpath, self.web["faq_title"]: self.faq_button_xpath, self.web["contact_title"]: self.contact_button_xpath} for key, value in data.items(): with self.subTest(key): expected_text = key self.home_page.visit() self.click_button(value) self.assert_page_title(self.driver.current_url, expected_text)
class HomePageTests(BaseTestClass): web = web_reader.load() h1_titles_xpath = HomePageLocators.h1_titles_xpath email_input_xpath = HomePageLocators.email_input_xpath contact_text_field_xpath = HomePageLocators.contact_text_field_xpath send_form_button_xpath = HomePageLocators.send_form_button_xpath error_message_xpath = HomePageLocators.error_message_xpath sent_message_xpath = HomePageLocators.sent_message_xpath @screenshot def test_number_of_home_page_sections_with_h1_title(self): expected_images_number = 8 self.home_page.visit() page_sections = self.driver.find_elements_by_xpath( self.h1_titles_xpath) self.assertEqual( expected_images_number, len(page_sections), f"Required number of page sections does not match quantity on web {self.web['en_homepage_url']}" ) @screenshot def test_correctly_filled_form_sending(self): self.home_page.visit() home_page = page_factory.home_page(self.driver) home_page.text_to_input_field(self.email_input_xpath, '*****@*****.**') home_page.text_to_input_field(self.contact_text_field_xpath, 'Sample message text') self.click_button(self.send_form_button_xpath) self.assert_if_element_is_displayed(self.sent_message_xpath) @screenshot def test_not_filled_form_sending(self): self.home_page.visit() home_page = page_factory.home_page(self.driver) home_page.text_to_input_field(self.email_input_xpath, '*****@*****.**') self.click_button(self.send_form_button_xpath) self.assert_if_element_is_displayed(self.error_message_xpath) @screenshot def test_form_filled_with_wrong_inputs(self): self.home_page.visit() home_page = page_factory.home_page(self.driver) home_page.text_to_input_field(self.email_input_xpath, '1234') home_page.text_to_input_field(self.contact_text_field_xpath, 'uuuuuuuuuuu') self.click_button(self.send_form_button_xpath) self.assert_if_element_is_displayed(self.error_message_xpath)
class MainPageTests(BaseTestClass): web = web_reader.load() main_slider_xpath = MainPageLocators.main_slider_xpath en_menu_button_xpath = MainPageLocators.en_menu_button_xpath de_menu_button_xpath = MainPageLocators.de_menu_button_xpath fr_menu_button_xpath = MainPageLocators.fr_menu_button_xpath pl_menu_button_xpath = MainPageLocators.pl_menu_button_xpath mail_address_xpath = MainPageLocators.mail_address_xpath @screenshot def test_main_page_title(self): expected_title = "KANDELO - handmade candles" self.assert_page_title(self.web['main_url'], expected_title) @screenshot def test_images_number_in_slider(self): expected_images_number = 4 self.main_page.visit() slider_images = self.driver.find_elements_by_xpath(self.main_slider_xpath) self.assertEqual(expected_images_number, len(slider_images), f"Required number of images in slider do not match quantity on web {self.web['main_url']}") @screenshot def test_linked_page_title_after_each_main_page_menu_button_click(self): data = {self.web['en_homepage_title']: self.en_menu_button_xpath, self.web['de_homepage_title']: self.de_menu_button_xpath, self.web['pl_homepage_title']: self.pl_menu_button_xpath} for key, value in data.items(): with self.subTest(key): expected_text = key self.main_page.visit() self.click_button(value) self.assert_page_title(self.driver.current_url, expected_text) @screenshot def test_correct_email_link_href_value(self): expected_text = 'mailto:[email protected]?subject=contact%20from%20the%20web' self.main_page.visit() href_value = self.driver.find_element_by_xpath(self.mail_address_xpath).get_attribute('href') self.assertEqual(expected_text, href_value, f'Expected email link differ from {href_value}')
def __init__(self, driver): web = web_reader.load() self.url = web["en_products_url"] self.driver = driver
def __init__(self, driver): web = web_reader.load() self.url = web['main_url'] self.driver = driver
class ProductsPageTests(BaseTestClass): web = web_reader.load() products_titles_xpath = ProductsPageLocators.products_titles_xpath top_products_list_xpath = ProductsPageLocators.top_products_list_xpath products_gallery_xpath = ProductsPageLocators.products_gallery_xpath weight_field_xpath = ProductsPageLocators.weight_field_xpath dimensions_field_xpath = ProductsPageLocators.dimensions_field_xpath @screenshot def test_top_products_list_number_equals_titled_products_description_blocks( self): self.products_page.visit() top_products_list = self.driver.find_elements_by_xpath( self.top_products_list_xpath) titled_products_blocks = self.driver.find_elements_by_xpath( self.products_titles_xpath) # top_products_list minus 4 elements in the group (additional 2 lines and 2 section titles) self.assertEqual( len(top_products_list) - 4, len(titled_products_blocks), f"Number of product blocks differ from top product links quantity on page {self.web['en_products_url']}" ) @screenshot def test_product_blocks_number_equals_products_image_galleries(self): self.products_page.visit() products_blocks = self.driver.find_elements_by_xpath( self.products_titles_xpath) galleries_list = self.driver.find_elements_by_xpath( self.products_gallery_xpath) self.assertEqual( len(products_blocks), len(galleries_list), f"Required number of page sections does not match product galleries quantity on web {self.web['en_products_url']}" ) @screenshot def test_product_weight_information_number_equals_product_blocks_quantity( self): self.products_page.visit() products_blocks = self.driver.find_elements_by_xpath( self.products_titles_xpath) product_weight_information = self.driver.find_elements_by_xpath( self.weight_field_xpath) self.assertEqual( len(products_blocks), len(product_weight_information), f"Products blocks number not equals weight information occurrences on web {self.web['en_products_url']}" ) @screenshot def test_product_dimension_information_number_equals_product_blocks_quantity( self): self.products_page.visit() products_blocks = self.driver.find_elements_by_xpath( self.products_titles_xpath) product_dimensions_information = self.driver.find_elements_by_xpath( self.dimensions_field_xpath) # products_blocks minus 1 element in the group (one product doesn't have dimensions info) self.assertEqual( len(products_blocks) - 1, len(product_dimensions_information), f"Products blocks number not equals dimensions information occurrences on web {self.web['en_products_url']}" )
def __init__(self, driver): web = web_reader.load() self.url = web['en_homepage_url'] self.driver = driver