From 189af30264e388889620c3c8f5160e0f36efb3e3 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Thu, 4 Sep 2025 10:37:59 +0200 Subject: [PATCH 1/4] fix failed tests --- pages/base_page.py | 3 +++ pages/cart_page.py | 5 +---- pages/main_page.py | 6 +++--- tests/cart_page_test.py | 5 +++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pages/base_page.py b/pages/base_page.py index 95dd017..423bf62 100644 --- a/pages/base_page.py +++ b/pages/base_page.py @@ -35,6 +35,9 @@ def expect_to_have_value(self, element, value): def expect_to_have_text(self, element, text_value): self._expect(element).to_have_text(text_value) + def expect_to_contain_text(self, element, text_value): + self._expect(element).to_contain_text(text_value) + def expect_to_have_attribute(self, element, attr_name, attr_value): self._expect(element).to_have_attribute(attr_name, attr_value) diff --git a/pages/cart_page.py b/pages/cart_page.py index 622e751..9b444b5 100644 --- a/pages/cart_page.py +++ b/pages/cart_page.py @@ -28,8 +28,5 @@ def quantity_box_value(self): def quantity_box_remove_button(self): return self.find_by_locator(self.quantity_box(), '[data-ta="quantity-remove"]') - def empty_cart_section(self): - return self.find_by_page_locator('.css-ndkvgn-emptyCart') - def empty_cart_section_title(self): - return self.find_by_locator(self.empty_cart_section(), '.css-z8hido-emptyCartTitle') + return self.find_by_page_locator('section[class*="CartApp"]') diff --git a/pages/main_page.py b/pages/main_page.py index 62fc7f8..256de34 100644 --- a/pages/main_page.py +++ b/pages/main_page.py @@ -1,5 +1,5 @@ -from pages.base_page import BasePage from config import BASE_URL +from pages.base_page import BasePage class MainPage(BasePage): @@ -11,7 +11,7 @@ def go_to(self): self._page.goto(self._url) def popup(self): - return self.find_by_page_locator('[class*="CookiesConsentsBannerRodoHelper"]') + return self.find_by_page_locator('[class*="CookiesConsentsBannerRodo-module_wrapper"]') def popup_text_element(self): return self.find_by_text("Prywatność Użytkownika") @@ -21,7 +21,7 @@ def desktop_buttons(self): def accept_button(self): return self.find_by_page_locator( - '//div[contains(@class, "buttonsDesktop")]/button[@data-ta="cookie-btn-accept-all"]' + '[class*="InfoPage-module_buttonsDesktop"] [data-ta="cookie-btn-accept-all"]' ) def user_menu(self): diff --git a/tests/cart_page_test.py b/tests/cart_page_test.py index 0149409..2073a63 100644 --- a/tests/cart_page_test.py +++ b/tests/cart_page_test.py @@ -1,3 +1,5 @@ +import pdb + import allure import pytest @@ -65,8 +67,7 @@ def verify_and_remove_from_cart(cart_page, product_name_text, product_price_text cart_page.click(cart_page.quantity_box_remove_button()) cart_page.expect_not_to_be_visible(cart_page.quantity_box()) - cart_page.expect_to_be_visible(cart_page.empty_cart_section()) - cart_page.expect_to_have_text(cart_page.empty_cart_section_title(), 'Twój koszyk jest pusty') + cart_page.expect_to_contain_text(cart_page.empty_cart_section_title(), 'Twój koszyk jest pusty') @pytest.mark.parametrize('product', PRODUCTS_NAMES) From 3eedf3dbbcad831fa353bb2a7a535c18af98949c Mon Sep 17 00:00:00 2001 From: Evgenii Date: Thu, 4 Sep 2025 10:39:51 +0200 Subject: [PATCH 2/4] clean up --- tests/cart_page_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/cart_page_test.py b/tests/cart_page_test.py index 2073a63..343b3a6 100644 --- a/tests/cart_page_test.py +++ b/tests/cart_page_test.py @@ -1,5 +1,3 @@ -import pdb - import allure import pytest From d76c82f18387395e52de6a9807cb10a5fd9c1d45 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Thu, 4 Sep 2025 10:46:41 +0200 Subject: [PATCH 3/4] add flexible timeouts --- tests/conftest.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9429195..bc5ee63 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,36 +6,49 @@ from pages.cart_page import CartPage from utils.helpers import close_popup_if_visible +# --- Global timeout defaults in milliseconds --- +GLOBAL_DEFAULT_TIMEOUT = 10000 # 10 sec for all locators +GLOBAL_NAVIGATION_TIMEOUT = 20000 # 20 sec for navigation @pytest.fixture def main_page(page: Page) -> MainPage: - """Fixture to initialize the MainPage and ensure it's open.""" + """Fixture to initialize the MainPage with global timeouts and ensure it's open.""" + # Set global flexible timeouts + page.set_default_timeout(GLOBAL_DEFAULT_TIMEOUT) + page.set_default_navigation_timeout(GLOBAL_NAVIGATION_TIMEOUT) + page_model = MainPage(page) if page.url != page_model.url: page_model.open_page() - # Close cookies popup when it is visible on page + # Close cookies popup if visible close_popup_if_visible(page_model) return page_model - @pytest.fixture def search_page(page: Page) -> SearchPage: - """Fixture to initialize the SearchPage and ensure it's open.""" + """Fixture to initialize the SearchPage with global timeouts.""" + page.set_default_timeout(GLOBAL_DEFAULT_TIMEOUT) + page.set_default_navigation_timeout(GLOBAL_NAVIGATION_TIMEOUT) + page_model = SearchPage(page) return page_model - @pytest.fixture def product_page(page: Page) -> ProductPage: - """Fixture to initialize the ProductPage and ensure it's open.""" + """Fixture to initialize the ProductPage with global timeouts.""" + page.set_default_timeout(GLOBAL_DEFAULT_TIMEOUT) + page.set_default_navigation_timeout(GLOBAL_NAVIGATION_TIMEOUT) + page_model = ProductPage(page) return page_model - @pytest.fixture def cart_page(page: Page) -> CartPage: - """Fixture to initialize the CartPage and ensure it's open.""" + """Fixture to initialize the CartPage with global timeouts.""" + page.set_default_timeout(GLOBAL_DEFAULT_TIMEOUT) + page.set_default_navigation_timeout(GLOBAL_NAVIGATION_TIMEOUT) + page_model = CartPage(page) - return page_model + return page_model \ No newline at end of file From 0ab3c629e28ec554e511d903ba949255c070c554 Mon Sep 17 00:00:00 2001 From: Evgenii Date: Thu, 4 Sep 2025 11:22:14 +0200 Subject: [PATCH 4/4] let's deploy on any branches --- .github/workflows/github-actions.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index c154fa8..a19aeab 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -61,13 +61,16 @@ jobs: deploy: needs: run-tests runs-on: ubuntu-latest - name: Deploy to GitHub Pages - environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file + uses: actions/deploy-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./allure-report \ No newline at end of file