Skip to content

Commit 595aa39

Browse files
committed
Add responsive add-item test with visibility checks
1 parent 0e6d2a6 commit 595aa39

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

pages/inventory_page.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,11 @@ def get_prices(self):
5757
prices.append(price)
5858
return prices
5959

60+
def is_add_button_visible(self, product_key):
61+
add_selector = PRODUCTS[product_key]["add"]
62+
try:
63+
add_button = self.wait.until(EC.visibility_of_element_located(add_selector))
64+
return add_button.is_displayed()
65+
except TimeoutException:
66+
return False
67+

test/reports/report.html

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

test/test_inventory.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,23 @@ def test_get_prices(inventory_page):
5959
assert all(isinstance(p, float) for p in prices)
6060
assert min(prices) >0
6161

62+
63+
@pytest.mark.parametrize("viewport", [("desktop", 1920, 1080), ("mobile", 375, 667)])
64+
@pytest.mark.responsive
65+
def test_add_item_responsive(inventory_page, viewport):
66+
name, w, h = viewport
67+
with allure.step(f"Resize a {name} viewport({w}x{h})"):
68+
inventory_page.driver.set_window_size(w, h)
69+
product_key = ('bike_light')
70+
with allure.step(f"Check add button is visible on {name}"):
71+
visible = inventory_page.is_add_button_visible(product_key)
72+
assert visible, f"Not visible on {name}"
73+
allure.attach(str(visible), name="Visibility Check", attachment_type=allure.attachment_type.TEXT)
74+
with allure.step(f"add product {product_key}"):
75+
inventory_page.add_product(product_key)
76+
with allure.step("Check Badge=1"):
77+
badge = inventory_page.get_cart_badge_count()
78+
assert badge == "1", f"Expected '1', got {badge} en {name}"
79+
print(f"{name}: {badge}")
80+
allure.attach(badge, name="Badge Count", attachment_type=allure.attachment_type.TEXT)
81+

0 commit comments

Comments
 (0)