OrderTransaction.feature
Code: Select all
Feature: Transfer functionality
Scenario: login
Given I launch the application using the url
And I click the Sign In button
< /code>
Home.py
from playwright.sync_api import expect, Page
class HomePage:
def __init__(self, page:Page):
self.page = page
def navigate(self):
self.page.goto("https://rahulshettyacademy.com/loginpagePractise/")
def click_signin(self):
self.page.locator("#SignIn").click()
< /code>
conftest.py
import pytest
def pytest_addoption(parser):
parser.addoption(
"--browser_name", action="store", default="chrome", help="browser selection"
)
parser.addoption(
"--url_name", action="store", default="https://rahulshettyacademy.com/loginpagePractise/", help="server selection"
)
@pytest.fixture(scope="session")
def user_credentials(request):
return request.param
@pytest.fixture
def browserInstance(playwright, request):
browser_name = request.config.getoption("browser_name")
url_name = request.config.getoption("url_name")
if browser_name == "chrome":
browser = playwright.chromium.launch(headless=False)
elif browser_name == "firefox":
browser = playwright.firefox.launch(headless=False)
context = browser.new_context()
page = context.new_page()
#page.goto(url_name)
yield page
context.close()
browser.close()
#2 times, 1st run opened browser and completed, homepage
< /code>
TEST_PYTESTBDDSTEPS.PY
import pytest
import time
from pytest_bdd import given, when, then, scenarios, parsers
from pageobjects.home import HomePage
scenarios('features/coreFunctions.feature')
@pytest.fixture
def shared_data():
return {}
@given('I launch the application using the url')
def launch_application(browserInstance):
homePage = HomePage(browserInstance)
homePage.navigate()
time.sleep(2)
@given(parsers.parse('I click the Sign In button'))
def sign_in_button():
#--does not work--
#HomePage.click_signin()
# --does not work--
drive = HomePage()
drive.click_signin()