From 6314ff6ab84d97fa91cf12c73b4f82e10435ba80 Mon Sep 17 00:00:00 2001 From: Cruz06 Date: Fri, 3 May 2024 21:11:51 +0300 Subject: [PATCH] sports wear items and username on each page --- pages/locators.py | 11 +++++++++++ tests/auth/test_sign_in.py | 13 ++++++++++++- tests/test_performance_sportswear.py | 27 +++++++++++++++++++++++++++ tests/{auth => }/test_search_page.py | 0 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/test_performance_sportswear.py rename tests/{auth => }/test_search_page.py (100%) diff --git a/pages/locators.py b/pages/locators.py index 364de8f3..dc963213 100644 --- a/pages/locators.py +++ b/pages/locators.py @@ -58,6 +58,15 @@ class BaseLocators: PAGE_TITLE = 'h1' BREADCRUMBS_LIST = ".breadcrumbs li" BREADCRUMBS_LINKS = '.breadcrumbs > ul > li > a' + PRODUCT_ITEM_IN_CATALOG = 'li.product-item' # каждый товар на любой странице в целом + PRODUCT_PRICE = '.price-label' + PRODUCT_NAME = '.product-item-link' + PRODUCT_IMAGE = '.product-image-photo' + ALL_URL = ["https://magento.softwaretestingboard.com/", + "https://magento.softwaretestingboard.com/what-is-new.html", + "https://magento.softwaretestingboard.com/women/tops-women/jackets-women.html," + "https://magento.softwaretestingboard.com/training.html" + ] class SearchTermsLocators: @@ -77,3 +86,5 @@ class LoginLocators: LINK_ACCOUNT = 'https://magento.softwaretestingboard.com/customer/account/' +class PerformanceSportswear: + LINK_SPORT = "https://magento.softwaretestingboard.com/collections/performance-new.html" diff --git a/tests/auth/test_sign_in.py b/tests/auth/test_sign_in.py index c7ec498b..648ffb49 100644 --- a/tests/auth/test_sign_in.py +++ b/tests/auth/test_sign_in.py @@ -1,5 +1,7 @@ +import pytest + from pages import sign_in, my_account, message -from pages.locators import LoginLocators +from pages.locators import LoginLocators, BaseLocators from selene import browser, be, have from selene.support.shared.jquery_style import s @@ -33,5 +35,14 @@ def test_004_005_002_login_successful(): s(LoginLocators.AUTHORIZATION_LINK).should(have.no.text("Sign In")) +def test_004_005_003_nickname_on_each_page(): + # I used only 4 links, otherwise test will take too much time + browser.open(LoginLocators.LINK_LOGIN) + s(LoginLocators.FIELD_NAME).type("ahahah1@gmail.com") + s(LoginLocators.FIELD_PASSWORD).type("jk$34_tor") + s(LoginLocators.BUTTON_SUBMIT).click() + for lnk in BaseLocators.ALL_URL: + browser.open(lnk) + s(LoginLocators.USER_NAME_IN_WELCOME).should(have.text("фы ывф")) diff --git a/tests/test_performance_sportswear.py b/tests/test_performance_sportswear.py new file mode 100644 index 00000000..037e8d03 --- /dev/null +++ b/tests/test_performance_sportswear.py @@ -0,0 +1,27 @@ +import pytest +from selene.support.conditions.have import values_containing, values +from selenium.webdriver.common.by import By + +from pages.locators import PerformanceSportswear, BaseLocators +from selene import browser, be, have, query +from selene.support.shared.jquery_style import s, ss +from selene.support.conditions import be, have + + +def test_006_008_001_visibility_of_price_photo_name(): + # I can't count elements on the page via selen + browser.open(PerformanceSportswear.LINK_SPORT) + ss(BaseLocators.PRODUCT_NAME).should(have.size(5)) + ss(BaseLocators.PRODUCT_PRICE).should(have.size(5)) + ss(BaseLocators.PRODUCT_IMAGE).should(have.size(5)) + + +def test_006_008_001_visibility_of_price_photo_name_selenium(driver): + # I have to find actual nr of elements on the page via python/selenium + browser.open(PerformanceSportswear.LINK_SPORT) + driver.get(PerformanceSportswear.LINK_SPORT) + nr_of_items_on_page = len(driver.find_elements(By.CSS_SELECTOR, BaseLocators.PRODUCT_ITEM_IN_CATALOG)) + ss(BaseLocators.PRODUCT_NAME).should(have.size(nr_of_items_on_page)) + ss(BaseLocators.PRODUCT_PRICE).should(have.size(nr_of_items_on_page)) + ss(BaseLocators.PRODUCT_IMAGE).should(have.size(nr_of_items_on_page)) + diff --git a/tests/auth/test_search_page.py b/tests/test_search_page.py similarity index 100% rename from tests/auth/test_search_page.py rename to tests/test_search_page.py