Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 1 addition & 2 deletions pages/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SalePageLocators:
GEAR_DEALS_TITLE = "//*[text()='Gear Deals']"
BAGS_LINK = "//a[text()='Bags']"
FITNESS_EQUIPMENT_LINK = "//a[text()='Fitness Equipment']"
LINK_SALE = "https://magento.softwaretestingboard.com/sale.html"

LINK_WOMEN_SALE = "https://magento.softwaretestingboard.com/promotions/women-sale.html"
LINK_TEES_WOMEN = "https://magento.softwaretestingboard.com/women/tops-women/tees-women.html"

Expand Down Expand Up @@ -89,7 +89,6 @@ class BaseLocators:


class SearchTermsLocators:
LINK_SEARCH_TERMS = "https://magento.softwaretestingboard.com/search/term/popular/"
TERMS_FOR_SEARCH_LIST_QTY = '[class="item"]'
LIST_OF_SEARCH_TERMS = '[class="item"] a'

Expand Down
10 changes: 9 additions & 1 deletion pages/urls.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
main_page_link = "https://magento.softwaretestingboard.com"
checkout_cart = "https://magento.softwaretestingboard.com/checkout/cart/"
LINK_SPORT = "https://magento.softwaretestingboard.com/collections/performance-new.html"
LINK_LOGIN = 'https://magento.softwaretestingboard.com/customer/account/login'
LINK_ACCOUNT = 'https://magento.softwaretestingboard.com/customer/account/'
LINK_SEARCH_TERMS = "https://magento.softwaretestingboard.com/search/term/popular/"
LINK_SALE = "https://magento.softwaretestingboard.com/sale.html"
LINK_WOMEN_SALE = "https://magento.softwaretestingboard.com/promotions/women-sale.html"
LINK_TEES_WOMEN = "https://magento.softwaretestingboard.com/women/tops-women/tees-women.html"
checkout_cart = "https://magento.softwaretestingboard.com/checkout/cart/"

17 changes: 9 additions & 8 deletions tests/test_performance_sportswear.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from selene.support.conditions.have import values_containing, values
from selenium.webdriver.common.by import By

from pages.urls import *
from pages.locators import PerformanceSportswear, BaseLocators, LoginLocators, ProductLocators
from selene import browser, be, have, query, command
from selene.support.shared.jquery_style import s, ss
Expand All @@ -12,24 +12,24 @@

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)
browser.open(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)
browser.open(LINK_SPORT)
driver.get(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))


def test_006_008_002_add_to_cart_from_catalog_without_color_and_size():
browser.open(LoginLocators.LINK_LOGIN)
browser.open(LINK_LOGIN)
s(LoginLocators.FIELD_NAME).type("ahahah1@gmail.com")
s(LoginLocators.FIELD_PASSWORD).type("jk$34_tor")
s(LoginLocators.BUTTON_SUBMIT).click()
Expand All @@ -38,8 +38,9 @@ def test_006_008_002_add_to_cart_from_catalog_without_color_and_size():
s(PerformanceSportswear.BUTTON_ADD_ITEM2).perform(command.js.click)
s(PerformanceSportswear.SUCCESS_MESSAGE).should(have.no.text(PerformanceSportswear.TEXT_SUCCESS_MESSAGE))


def test_006_008_002_add_to_cart_from_catalog_without_color_and_size_with_hover():
browser.open(LoginLocators.LINK_LOGIN)
browser.open(LINK_LOGIN)
s(LoginLocators.FIELD_NAME).type("ahahah1@gmail.com")
s(LoginLocators.FIELD_PASSWORD).type("jk$34_tor")
s(LoginLocators.BUTTON_SUBMIT).click()
Expand All @@ -51,7 +52,7 @@ def test_006_008_002_add_to_cart_from_catalog_without_color_and_size_with_hover(


def test_006_008_003_color_and_size_can_be_checked():
browser.open(LoginLocators.LINK_LOGIN)
browser.open(LINK_LOGIN)
s(LoginLocators.FIELD_NAME).type("ahahah1@gmail.com")
s(LoginLocators.FIELD_PASSWORD).type("jk$34_tor")
s(LoginLocators.BUTTON_SUBMIT).click()
Expand All @@ -64,7 +65,7 @@ def test_006_008_003_color_and_size_can_be_checked():


def test_006_008_004_add_to_cart_from_product_page_without_color_and_size():
browser.open(LoginLocators.LINK_LOGIN)
browser.open(LINK_LOGIN)
s(LoginLocators.FIELD_NAME).type("ahahah1@gmail.com")
s(LoginLocators.FIELD_PASSWORD).type("jk$34_tor")
s(LoginLocators.BUTTON_SUBMIT).click()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_sale_page.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from selene import browser, be, have
from selene.support.shared.jquery_style import s, ss
from pages.locators import SalePageLocators, BaseLocators
from pages.urls import *
import allure


Expand Down Expand Up @@ -63,7 +64,7 @@ def test_fitness_link_correct_redirection():


def test_011_001_001_sale_breadcrumbs_is_correct():
browser.open(SalePageLocators.LINK_SALE)
browser.open(LINK_SALE)
ss(BaseLocators.BREADCRUMBS_LIST).should(have.texts('Home', 'Sale'))


58 changes: 25 additions & 33 deletions tests/test_search_terms.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
from selenium.webdriver.common.by import By

from pages.urls import *
from pages.locators import SearchTermsLocators as ST
from pages.locators import BaseLocators as Base
from selene import browser, be, have, query
from selene.support.shared.jquery_style import s, ss


def test_015_001_001_search_terms_title_is_visible():
browser.open(ST.LINK_SEARCH_TERMS)
browser.open(LINK_SEARCH_TERMS)
s(Base.PAGE_TITLE).should(have.text("Popular Search Terms"))


# def test_015_001_001_selenium(driver):
# driver.get(ST.LINK_SEARCH_TERMS)
# driver.get(LINK_SEARCH_TERMS)
# expected_title = "Popular Search Terms"
# actual_title = driver.find_element(*Base.PAGE_TITLE).text
# assert expected_title == actual_title, "Page title is not correct"


def test_015_001_002_count_search_terms():
browser.open(ST.LINK_SEARCH_TERMS)
browser.open(LINK_SEARCH_TERMS)
ss(ST.TERMS_FOR_SEARCH_LIST_QTY).should(have.size(100))


# def test_015_001_002_selenium(driver):
# driver.get(ST.LINK_SEARCH_TERMS)
# driver.get(LINK_SEARCH_TERMS)
# q_of_goods = len(driver.find_elements(*ST.TERMS_FOR_SEARCH_LIST_QTY))
# assert q_of_goods == 100, "Nr of search terms is not equal to 100"


def test_015_001_003_check_if_search_terms_has_size_from_76_till_136():
# assert from selenium - how to check sizes
browser.open(ST.LINK_SEARCH_TERMS)
browser.open(LINK_SEARCH_TERMS)
list_font_sizes = []
terms = ss(ST.LIST_OF_SEARCH_TERMS)
for g in terms:
Expand All @@ -42,7 +42,7 @@ def test_015_001_003_check_if_search_terms_has_size_from_76_till_136():


def test_015_001_003_check_if_search_terms_has_size_from_76_till_136_selenium(driver):
driver.get(ST.LINK_SEARCH_TERMS)
driver.get(LINK_SEARCH_TERMS)
list_font_sizes = []
terms = driver.find_elements(By.CSS_SELECTOR, ST.LIST_OF_SEARCH_TERMS)
for g in terms:
Expand All @@ -57,7 +57,7 @@ def test_015_001_003_check_if_search_terms_has_size_from_76_till_136_selenium(dr


def test_015_001_004_check_if_5_search_terms_is_bigger(driver):
driver.get(ST.LINK_SEARCH_TERMS)
driver.get(LINK_SEARCH_TERMS)
list_font_sizes = []
terms = driver.find_elements(By.CSS_SELECTOR, ST.LIST_OF_SEARCH_TERMS)
for g in terms:
Expand All @@ -70,9 +70,9 @@ def test_015_001_004_check_if_5_search_terms_is_bigger(driver):
assert False, "List of search terms has not 5 elements which size is bigger than 88%"


def test_015_001_005_check_if_specified_words_is_bigger_than_88(driver):
def test_015_001_005_check_if_specified_words_is_bigger_than_88_selenium(driver):
words = ["HOODIE", "jacket", "pants", "shirt"]
driver.get(ST.LINK_SEARCH_TERMS)
driver.get(LINK_SEARCH_TERMS)
list_of_goods = []
list_font_sizes = []
terms = driver.find_elements(By.CSS_SELECTOR, ST.LIST_OF_SEARCH_TERMS)
Expand All @@ -89,49 +89,41 @@ def test_015_001_005_check_if_specified_words_is_bigger_than_88(driver):
[size > 88 for size in list_font_sizes]), "Selected words have font size bigger thjan 88%"


def test_015_001_005_check_if_specified_words_is_bigger_than_88_selenium(driver):
words = ["HOODIE", "jacket", "pants", "shirt"]
driver.get(ST.LINK_SEARCH_TERMS)
def test_015_001_005_check_if_specified_words_is_bigger_than_88():
words = ["hoodie", "jacket", "pants", "shirt"]
browser.open(LINK_SEARCH_TERMS)
list_of_goods = []
list_font_sizes = []
terms = driver.find_elements(By.CSS_SELECTOR, ST.LIST_OF_SEARCH_TERMS)
for g in terms:
if g.text in words:
list_of_goods.append(g.text)
g_font, g_size = g.get_attribute("style").split(": ")
g_size = g_size.replace("%;", "")
g_size = float(g_size)
terms = ss(ST.LIST_OF_SEARCH_TERMS)
for keyword in terms:
word = keyword.get(query.attribute("text")).strip().replace(" ", "").lower()
if word in words:
list_of_goods.append(word)
g_font, g_size = keyword.get(query.attribute("style")).split(": ")
g_size = float(g_size.replace("%;", ""))
list_font_sizes.append(g_size)
# print(list_of_goods)
# print(list_font_sizes)
assert set(list_of_goods) == set(words) and all(
[size > 88 for size in list_font_sizes]), "Selected words have font size bigger thjan 88%"
[size > 88 for size in list_font_sizes]), "Selected words have font size bigger than 88%"


def test_015_001_006_check_if_search_terms_are_sorted():
# список ключевых,вытаскиваемых с помощью selene, выглядит не так, как при selenium.
# Теперь есть лишние пробелы, перевод строки, слова с малой буквы неправильно сортируются.
# С selenium тест = ОК
browser.open(ST.LINK_SEARCH_TERMS)
browser.open(LINK_SEARCH_TERMS)
list_of_goods = [] # good : strip, lower, no spaces
list_of_goods0 = [] # words from terms applied lower()
list_of_goods_from_terms = [] # words from terms applied lower()
terms = ss(ST.LIST_OF_SEARCH_TERMS)
for keyword in terms:
keyword = keyword.get(query.attribute("text")).strip().replace(" ","").lower()
list_of_goods0.append(keyword.lower())
list_of_goods_from_terms.append(keyword.lower())
list_of_goods.append(keyword)
# print(list_of_goods0)
# print(list_of_goods)
# print(sorted(list_of_goods))
list_of_goods_sorted = sorted(list_of_goods)
assert list_of_goods0 == list_of_goods_sorted
assert list_of_goods_from_terms == list_of_goods_sorted


# def test_015_001_006_check_if_search_terms_are_sorted_selenium(driver):
# driver.get(ST.LINK_SEARCH_TERMS)
# list_of_goods = []
# terms = ss(ST.LIST_OF_SEARCH_TERMS)
# for g in terms:
# list_of_goods.append(g.text)
# sorted_list = sorted(list_of_goods)
# assert list_of_goods == sorted_list, "Goods are not sorted from A to Z"
39 changes: 39 additions & 0 deletions tests/test_shipping.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import time
from pages.urls import *
from pages.locators import WomenLocators, Shipping, Order
from selene import browser, be, have
from selene.support.shared.jquery_style import s, ss
from selene.support.conditions import be, have


def test_004_001_002_guest_user_checkout_from_minicart():
browser.open(LINK_WOMEN)
# choose item
s(WomenLocators.TANK_SIZE).click()
s(WomenLocators.TANK_COLOR).click()
s(WomenLocators.TANK_BUTTON_ADD).click()
time.sleep(2)
s(WomenLocators.MESSAGE_SUCCESS_ADD).should(have.text("You added"))
# open minicart
s(WomenLocators.SHOW_BASKET).should(be.clickable).click() # CHECK HERE
s(WomenLocators.CHECKOUT_BUTTON).should(be.visible)
s(WomenLocators.CHECKOUT_BUTTON).should(be.clickable).click()
# fill address
browser.should(have.url(LINK_SHIPPING))
s(Shipping.FIELD_EMAIL).type("email@mail.aaa")
s(Shipping.FIELD_FIRST_NAME).type("f_name")
s(Shipping.FIELD_LAST_NAME).type("l_name")
s(Shipping.FIELD_STREET).type("street")
s(Shipping.FIELD_CITY).type("city")
s(Shipping.FIELD_REGION).press("Alabama")
s(Shipping.FIELD_ZIPCODE).type("MD2060")
s(Shipping.FIELD_COUNTRY).press("Tanzania")
s(Shipping.FIELD_PHONE).type("1234567890")
s(Shipping.SHIPPING_METHOD).should(be.clickable).click()
s(Shipping.CONTINUE_BUTTON).should(be.clickable).click()
browser.should(have.url(LINK_PAYMENT))
# check data and place order
s(Order.BUTTON_PLACE_ORDER).click()
s(Order.MESSAGE_SUCCEES).should(have.text("Your order # is"))
s(Order.ORDER_PAGE_TITLE).should(have.text("Thank you for your purchase!"))

11 changes: 6 additions & 5 deletions tests/test_women_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from pages.locators import SalePageLocators, BaseLocators
from selene import browser, be, have
from selene.support.shared.jquery_style import s, ss
from pages.urls import *


# @pytest.mark.xfail
# def test_011_011_001_selenium(driver):
# # assert error !!! 'Sale' is missing
# driver.get(SalePageLocators.LINK_WOMEN_SALE)
# driver.get(LINK_WOMEN_SALE)
# list_br = driver.find_elements(*BaseLocators.BREADCRUMBS_LIST)
# expected_list_breadcrumbs = ['Home', 'Sale', 'Women Sale']
# actual_list_breadcrumbs = []
Expand All @@ -18,12 +19,12 @@
@pytest.mark.skip
def test_011_011_001_women_sale_breadcrumbs_is_correct():
# assert error !!! 'Sale' is missing
browser.open(SalePageLocators.LINK_WOMEN_SALE)
browser.open(LINK_WOMEN_SALE)
ss(BaseLocators.BREADCRUMBS_LIST).should(have.texts('Home', 'Sale', 'Women Sale'))


# def test_011_011_002_selenium(driver):
# driver.get(SalePageLocators.LINK_WOMEN_SALE)
# driver.get(LINK_WOMEN_SALE)
# breadcrumbs_links = driver.find_elements(*BaseLocators.BREADCRUMBS_LINKS)
# links = [elem.get_attribute('href') for elem in breadcrumbs_links]
# for elem in links:
Expand All @@ -32,7 +33,7 @@ def test_011_011_001_women_sale_breadcrumbs_is_correct():
#

def test_011_011_002_breadcrumbs_redirection_from_women_sale():
browser.open(SalePageLocators.LINK_WOMEN_SALE)
browser.open(LINK_WOMEN_SALE)
elements = ss(BaseLocators.BREADCRUMBS_LINKS).by(have.attribute('href'))
expected_links = ['https://magento.softwaretestingboard.com/',
'https://magento.softwaretestingboard.com/sale.html']
Expand All @@ -41,7 +42,7 @@ def test_011_011_002_breadcrumbs_redirection_from_women_sale():


# def test_011_011_002_breadcrumbs_redirection_from_women_sale():
# browser.open(SalePageLocators.LINK_WOMEN_SALE)
# browser.open(LINK_WOMEN_SALE)
# # breadcrumbs_links = ss(BaseLocators.BREADCRUMBS_LINKS)
# links = ss(BaseLocators.BREADCRUMBS_LINKS).filtered_by(have.attribute('href'))
#
Expand Down
Loading