I'm doing an end-to-end test automation project in which I simply login to a specific page. To do this, I use Python 3.10, Pytest, Playwright and Allure to report. In my implementation file of my feature, when executing in console: pytest --headed --alluredir=C:.../RefactorPlay/surefire-reports. It returns me no tests ran referring to the fact that no test case to be executed is found.

Implementation file:

from playwright.sync_api import Page
import allure
from pytest_bdd import scenario, given, when, then
from pages.ican_login import ICanLogin

@scenario('Inicio de sesion con usuario y contraseña')
def test_example_is_working_bdd():
    print('starting bdd test')

@given("El usuario se ha registrado previamente, y los ingresa correctamente.")
def goto_website(page):
    login_page = ICanLogin(page)
    login_page.fill_input_user("[email protected]")

@when("El usuario hace clic sobre el boton ingresar.")
def login_to_the_system(page):
    login_page = ICanLogin(page)

@then('El usuario puede ingresar sesion a su cuenta correctamente.')
def check_ican_nav_menu(page):
    content = page.text_content("//html/body/main/aside/section/div/div[2]/div/a")
    assert content == "CONTENIDO"

feature file:

Feature: Inicio Sesion en test Sistema
  # Enter feature description here

  Scenario: Inicio de sesion con usuario y contraseña

  Given El usuario se ha registrado previamente, y los ingresa correctamente.
    When El usuario hace clic sobre el boton ingresar.
  Then El usuario puede ingresar sesion a su cuenta correctamente.

icanlogin.py file:

from playwright.sync_api import Page

class ICanLogin:
    def __init__(self, page: Page):
        self.page = page

    # Web Elements
    user: str = "#Usuario"
    password: str = "#password"
    submit: str = "#btnIngresar"
    u_forgot: str = "div:text('¿Olvidaste la contraseña?')"
    corporation_sign_up: str = "div:text('Registro de Empresas')"

    def verify_elements_is_presents(self):

    def fill_input_user(self, value):
        with self.page.expect_navigation():
            self.page.fill(self.user, value)

    def fill_input_password(self, value):
        with self.page.expect_navigation():
            self.page.fill(self.password, value)

    def select_submit(self):
        with self.page.expect_navigation():

    def select_u_forgot(self):
        with self.page.expect_navigation():

    def select_corporation_sign_up(self):
        with self.page.expect_navigation():

console error:

pytest --headed --alluredir=C:/Users/.../Desktop/RefactorPlay/surefire-reports
=============================================== test session starts ================================================
platform win32 -- Python 3.10.6, pytest-7.1.2, pluggy-1.0.0
rootdir: C:\Users\...\Desktop\RefactorPlay
plugins: allure-pytest-2.12.0, asyncio-0.20.3, base-url-2.0.0, bdd-6.1.1, dependency-0.5.1, html-3.1.1, metadata-2.0.2, playwright-0.3.0, rerunfailures-10.3
asyncio: mode=strict
collected 0 items

============================================== no tests ran in 0.04s ===============================================

I know that pytest takes functions that are prefixed with "test_ ..." as valid test cases. Try renaming my functions around it.

I can't detect what I'm doing wrong and I'm new to this. It's just a simple login.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.