Skip to content
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

Refactoring test TC005.001.011- TC005.001.017 #49

Merged
merged 1 commit into from
May 14, 2024
Merged
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
21 changes: 11 additions & 10 deletions pages/checkout_cart_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,27 @@ def check_color_button():


@allure.link("https://trello.com/c/lvLslLGD")
def checking_product_name_are_correct_in_checkout_cart_page():
s(PL.NAME_ARGUS_ALL_WEATHER_TANK_CHECKOUT_CART).should(have.text("Argus All-Weather Tank"))
def checking_product_name_are_correct_in_checkout_cart_page(item_name):
s(PL.NAME_ARGUS_ALL_WEATHER_TANK_CHECKOUT_CART).should(have.text(item_name))


def checking_size_are_correct_in_checkout_cart_page():
s(PL.SIZE_M_ARGUS_ALL_WEATHER_TANK_CHECKOUT_CART).should(have.text("M"))
def checking_size_are_correct_in_checkout_cart_page(size):
s(PL.SIZE_M_ARGUS_ALL_WEATHER_TANK_CHECKOUT_CART).should(have.text(size))


def checking_color_are_correct_in_checkout_cart_page():
s(PL.COLOR_GRAY_ARGUS_CHECKOUT_CART).should(have.text("Gray"))
def checking_color_are_correct_in_checkout_cart_page(color):
s(PL.COLOR_GRAY_ARGUS_CHECKOUT_CART).should(have.text(color))


@allure.link("https://trello.com/c/SQ3op4DX")
def check_price_present_in_checkout_cart_page():
s(PL.PRICE_ITEM_CHECKOUT_CART).should(be.present).should(have.text("$22.00"))
def check_price_present_in_checkout_cart_page(item_price):
s(PL.PRICE_ITEM_CHECKOUT_CART).should(be.present).should(have.text(item_price))


def check_qty_present_in_checkout_cart_page():
s(PL.QTY_FIELD_CHECKOUT_CART).should(be.present)


def check_subtotal_present_in_checkout_cart_page():
s(PL.CART_SUBTOTAL_CHECKOUT_CART).should(be.present).should(have.text("$"))
def check_subtotal_present_in_checkout_cart_page(subtotal):
s(PL.CART_SUBTOTAL_CHECKOUT_CART).should(be.present).should(have.text(subtotal))

13 changes: 9 additions & 4 deletions pages/home_page.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from selene.support.shared.jquery_style import s, ss
from selene import be
from selene.support.shared.jquery_style import s

from pages.base_page import BasePage
# from pages.basket_page import BasketPage
from pages.locators import NavigatorLocators as NL, ProductLocators as PL
from pages.urls import main_page_link


class HomePage(BasePage):
Expand All @@ -28,4 +27,10 @@ def go_to_mini_cart(self):
s(PL.MINI_BASKET_WINDOW).should(be.clickable).click()

def go_to_checkout_cart(self):
s(PL.VIEW_AND_EDIT_CART_LINK).click()
s(PL.VIEW_AND_EDIT_CART_LINK).click()

def find_counter_number(self):
return s(PL.MINICART_COUNTER)

def is_counter_number_visible(self):
return self.find_counter_number().should(be.visible)
2 changes: 1 addition & 1 deletion pages/locators.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ProductLocators:
PRICE_ITEM_CHECKOUT_CART = '//*[@class="col price"] //*[text()="$22.00"]'
CART_SUBTOTAL_CHECKOUT_CART = '//*[@class="col subtotal"] //*[text()="$22.00"]'
QTY_FIELD_CHECKOUT_CART = '[class="field qty"] input'

MINICART_COUNTER = '.counter-label'

class HomeLocators:
STORE_LOGO = 'a.logo'
Expand Down
32 changes: 16 additions & 16 deletions pages/mini_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ def checking_the_link_opens_checkout_cart_page():
s(PL.VIEW_AND_EDIT_CART_LINK).click()


def checking_the_size_color_and_product_name_are_correct():
def checking_the_size_color_and_product_name_are_correct(size, color, item_name):
s(PL.SEE_DETAILS).click()
s(PL.SIZE_M).should(have.text("M"))
s(PL.COLOR_GRAY).should(have.text("Gray"))
s(PL.NAME_ITEM).should(have.text("Argus All-Weather Tank"))
s(PL.SIZE_M).should(have.text(size))
s(PL.COLOR_GRAY).should(have.text(color))
s(PL.NAME_ITEM).should(have.text(item_name))


def checking_present_price_item_and_cart_subtotal_in_the_mini_cart():
s(PL.PRICE_ITEM).should(have.text("$22.00"))
s(PL.CART_SUBTOTAL).should(have.text("$22.00"))
def checking_present_price_item_and_cart_subtotal_in_the_mini_cart(price, subtotal):
s(PL.PRICE_ITEM).should(have.text(price))
s(PL.CART_SUBTOTAL).should(have.text(subtotal))


def change_qty():
s(PL.QTY_FIELD).should(be.clickable).send_keys(Keys.BACKSPACE + "7")
def change_qty(qty):
s(PL.QTY_FIELD).should(be.clickable).send_keys(Keys.BACKSPACE + qty)
s(PL.UPDATE).click()


def should_be_quantity_change():
s(PL.QTY_FIELD).should(have.value("7"))
def should_be_quantity_change(qty):
s(PL.QTY_FIELD).should(have.value(qty))
time.sleep(2)


def should_be_success_message():
def should_be_success_message(text):
s(".message-success").should(be.visible)
s(".message-success").should(have.text(text))


def should_be_change_subtotal():
s(PL.PRICE_ITEM).should(have.text("$22.00"))
s(PL.CART_SUBTOTAL).should(have.text("$154.00"))
def should_be_change_subtotal(price, subtotal):
s(PL.PRICE_ITEM).should(have.text(price))
s(PL.CART_SUBTOTAL).should(have.text(subtotal))
25 changes: 12 additions & 13 deletions tests/test_checkout.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import time

import allure
import pytest
import selene
from selene.support.shared.jquery_style import s, ss
from selene import browser, be, have
from selene.support.shared.jquery_style import s

from pages import mini_cart, checkout_shipping, checkout_cart_page
from pages.home_page import HomePage
from pages.locators import ProductLocators as PL
from pages.product_page import ProductPage
from pages.user import Person
from selene.support.conditions import *
from selene.support import by
from pages.urls import *
from pages.home_page import HomePage


@pytest.mark.skip
def test_checkout_from_mini_cart():
Expand Down Expand Up @@ -41,21 +40,21 @@ def test_size_color_and_product_name_are_correct_in_the_checkout_cart_page_tc_00
page = HomePage(browser, main_page_link)
page.open()
page.add_to_cart_from_main_page()
time.sleep(2)
page.is_counter_number_visible()
page.go_to_mini_cart()
page.go_to_checkout_cart()
checkout_cart_page.checking_product_name_are_correct_in_checkout_cart_page()
checkout_cart_page.checking_size_are_correct_in_checkout_cart_page()
checkout_cart_page.checking_color_are_correct_in_checkout_cart_page()
checkout_cart_page.checking_product_name_are_correct_in_checkout_cart_page("Argus All-Weather Tank")
checkout_cart_page.checking_size_are_correct_in_checkout_cart_page("M")
checkout_cart_page.checking_color_are_correct_in_checkout_cart_page("Gray")

@allure.link("https://trello.com/c/SQ3op4DX")
def test_check_price_qty_and_cart_subtotal_present_in_checkout_cart_page_tc_005_001_017():
page = HomePage(browser, main_page_link)
page.open()
page.add_to_cart_from_main_page()
time.sleep(2)
page.is_counter_number_visible()
page.go_to_mini_cart()
page.go_to_checkout_cart()
checkout_cart_page.check_price_present_in_checkout_cart_page()
checkout_cart_page.check_subtotal_present_in_checkout_cart_page()
checkout_cart_page.check_price_present_in_checkout_cart_page("$22.00")
checkout_cart_page.check_subtotal_present_in_checkout_cart_page("$22.00")
checkout_cart_page.check_qty_present_in_checkout_cart_page()
22 changes: 11 additions & 11 deletions tests/test_mini_cart_from_main_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_color_and_clickability_of_view_and_edit_cart_link_in_the_mini_cart_tc_0
page = HomePage(browser, main_page_link)
page.open()
page.add_to_cart_from_main_page()
time.sleep(2)
page.is_counter_number_visible()
page.go_to_mini_cart()
# mini_cart = BasketPage(browser, main_page_link)
mini_cart.check_color_of_view_and_edit_cart_link_in_the_mini_cart()
Expand All @@ -47,7 +47,7 @@ def test_checking_the_link_opens_the_cart_page_tc_005_001_012():
page = HomePage(browser, main_page_link)
page.open()
page.add_to_cart_from_main_page()
time.sleep(2)
page.is_counter_number_visible()
page.go_to_mini_cart()
mini_cart.checking_the_link_opens_checkout_cart_page()

Expand All @@ -57,29 +57,29 @@ def test_size_color_and_product_name_are_correct_tc_005_001_013():
page = HomePage(browser, main_page_link)
page.open()
page.add_to_cart_from_main_page()
time.sleep(2)
page.is_counter_number_visible()
page.go_to_mini_cart()
mini_cart.checking_the_size_color_and_product_name_are_correct()
mini_cart.checking_the_size_color_and_product_name_are_correct("M", "Gray", "Argus All-Weather Tank")


@allure.link("https://trello.com/c/p6iExP1c")
def test_checking_present_price_item_and_cart_subtotal_in_the_mini_cart_tc_005_001_014():
page = HomePage(browser, main_page_link)
page.open()
page.add_to_cart_from_main_page()
time.sleep(2)
page.is_counter_number_visible()
page.go_to_mini_cart()
mini_cart.checking_present_price_item_and_cart_subtotal_in_the_mini_cart()
mini_cart.checking_present_price_item_and_cart_subtotal_in_the_mini_cart("$22.00", "$22.00")


@allure.link("https://trello.com/c/uCZZgQks")
def test_change_quantity_of_an_item_and_changes_price_in_cart_subtotal_mini_cart_tc_005_001_015():
page = HomePage(browser, main_page_link)
page.open()
page.add_to_cart_from_main_page()
time.sleep(2)
page.is_counter_number_visible()
page.go_to_mini_cart()
mini_cart.should_be_success_message()
mini_cart.change_qty()
mini_cart.should_be_quantity_change()
mini_cart.should_be_change_subtotal()
mini_cart.should_be_success_message("You added Argus All-Weather Tank to your shopping cart.")
mini_cart.change_qty("7")
mini_cart.should_be_quantity_change("7")
mini_cart.should_be_change_subtotal("$22.00", "$154.00")
Loading