Skip to content

Commit

Permalink
fixed conftest configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
BohdanObruch committed Oct 30, 2024
1 parent a0c1f47 commit 7f19da0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from playwright.sync_api import Page
from playwright.sync_api import Page, Browser, BrowserContext

from playwright_tests_with_po.pages.login_page import LoginPage
from playwright_tests_with_po.pages.inventory_page import InventoryPage
from playwright_tests_with_po.pages.shopping_cart_page import ShoppingCartPage
Expand All @@ -11,6 +12,7 @@
def pytest_addoption(parser):
parser.addoption("--size", action="store", default="1920,1080", help="browser window size")


@pytest.fixture(scope="session")
def browser_context_args(browser_context_args, request):
device = request.config.getoption("--device")
Expand All @@ -23,14 +25,26 @@ def browser_context_args(browser_context_args, request):
return {
**browser_context_args,
"viewport": {"width": width, "height": height},
"screen": {"width": width, "height": height}

}

@pytest.fixture(autouse=True)
def page(page:Page):


@pytest.fixture(scope="function")
def page(context: BrowserContext) -> Page:
page = context.new_page()
yield page
page.close()


@pytest.fixture(scope="function")
def context(browser: Browser, browser_context_args) -> BrowserContext:
context = browser.new_context(**browser_context_args)
yield context
context.close()


@pytest.fixture
def login(page):
return LoginPage(page)
Expand Down

0 comments on commit 7f19da0

Please sign in to comment.