Skip to content

Commit 65c01dc

Browse files
committed
refcator: method to scroll to product card on category page
1 parent 4da5d37 commit 65c01dc

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tests_e2e/pages/category_page.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,21 @@ def get_product_card_by_sku(self, sku: str) -> ProductCardComponent | None:
8686
def scroll_to_product_card(
8787
self, sku: str, page_limit: int = 10
8888
) -> ProductCardComponent | None:
89+
product_card_locator = self.products_grid_view.locator(
90+
"[data-test-id='product-card']"
91+
)
8992
for _ in range(page_limit):
9093
product_card = self.get_product_card_by_sku(sku)
9194
if product_card:
9295
product_card.element.scroll_into_view_if_needed()
9396
return product_card
9497
if self.end_list_label.is_visible():
9598
break
99+
current_count = product_card_locator.count()
96100
with self.page.expect_response(
97101
lambda response: "/graphql" in response.url
98102
and response.status == 200
99103
):
100104
self.products_loader.scroll_into_view_if_needed()
105+
product_card_locator.nth(current_count).wait_for()
101106
return None

tests_e2e/tests/test_e2e_category_scroll_to_product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def test_e2e_category_scroll_to_product(
3030
product_card = category_page.scroll_to_product_card(product["code"])
3131

3232
assert product_card is not None, "Product card is not found"
33-
expect(product_card.element).to_be_visible(), "Product card is not visible"
33+
expect(product_card.element, "Product card is not visible").to_be_visible()

0 commit comments

Comments
 (0)