Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ jobs:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Set up python 3.10
- name: Set up python 3.13
uses: actions/setup-python@v6
with:
python-version: '3.10'
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ version: 2

# Set the version of Python and other tools you might need
build:
os: ubuntu-20.04
os: ubuntu-24.04
tools:
python: "3.10"
python: "3.13"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ v3.8.1
*Release date: In development*

- Add token usage tracking to OpenAI requests
- Add pytest and unittest runners documentation in `Docs <http://toolium.readthedocs.io/en/latest/tests_runners_integration.html>`_

v3.8.0
------
Expand Down Expand Up @@ -596,7 +597,7 @@ v1.3.0

*Release date: 2017-09-12*

- Add Behave dynamic environment (more info in `Docs <http://toolium.readthedocs.io/en/latest/bdd_integration.html#behave-dynamic-environment>`_)
- Add Behave dynamic environment (more info in `Docs <http://toolium.readthedocs.io/en/latest/tests_runners_integration.html#behave-dynamic-environment>`_)
- Fix visual screenshot filename error when behave feature name contains :
- Add a config property 'explicitly_wait' in [Driver] section to set the default timeout used in *wait_until* methods
- When reuse_driver is true using behave, driver is initialized in *before_feature* method and closed in *after_feature*
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Toolium is a Python wrapper tool of Selenium, Playwright and Appium libraries to
project. It provides a way of choosing and configuring the driver through a configuration file, implements a Page Object
pattern and includes a simple visual testing solution.

.. |Build Status| image:: https://github.com/Telefonica/toolium/workflows/build/badge.svg?branch=master
.. |Build Status| image:: https://github.com/Telefonica/toolium/actions/workflows/ci.yml/badge.svg?branch=master
:target: https://github.com/Telefonica/toolium/actions?query=branch%3Amaster
.. |Documentation Status| image:: https://readthedocs.org/projects/toolium/badge/?version=latest
:target: http://toolium.readthedocs.org/en/latest
Expand Down Expand Up @@ -100,7 +100,7 @@ Main Features

- `Choosing a driver through a configuration file </docs/driver_configuration.rst>`_
- `Page Object pattern </docs/page_objects.rst>`_
- `BDD integration </docs/bdd_integration.rst>`_
- `Tests runners integration </docs/tests_runners_integration.rst>`_
- `Visual testing solution </docs/visual_testing.rst>`_
- `Tests result analysis </docs/tests_result_analysis.rst>`_

Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Main Features

- :ref:`Choosing driver through a configuration file <driver_configuration>`
- :ref:`Page Object pattern <page_objects>`
- :ref:`BDD integration <bdd_integration>`
- :ref:`Tests runners integration <tests_runners_integration>`
- :ref:`AI utils <ai_utilities>`
- :ref:`Visual testing solution <visual_testing>`
- :ref:`Tests result analysis <tests_result_analysis>`
Expand All @@ -24,7 +24,7 @@ Library Reference

driver_configuration.rst
page_objects.rst
bdd_integration.rst
tests_runners_integration.rst
ai_utils.rst
visual_testing.rst
tests_result_analysis.rst
Expand All @@ -40,4 +40,4 @@ Indices and Tables

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
* :ref:`search`
79 changes: 74 additions & 5 deletions docs/bdd_integration.rst → docs/tests_runners_integration.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.. _bdd_integration:
.. _tests_runners_integration:

BDD Integration
===============
Tests runners integration
=========================

Behave
~~~~~~
Behave (BDD)
~~~~~~~~~~~~

Behave tests should be developed as usual, only *environment.py* file should be modified to initialize driver and the
rest of Toolium configuration.
Expand Down Expand Up @@ -260,3 +260,72 @@ returns the value of 'reference'
* mode with value offline will try to get a local copy of POEditor terms from output directory, online mode (by default if not provided) will download always terms from POEditor

* file_path contains relative path of downloaded POEditor terms file (default value: _output/poeditor_terms.json)

Nose2 / unittest
~~~~~~~~~~~~~~~~

To use Toolium with nose2 or unittest, you only need to extend from one of the base test case classes provided by Toolium:

- `BasicTestCase` for API tests
- `SeleniumTestCase` for Selenium tests
- `AppiumTestCase` for Appium tests

These classes already implement the setup and teardown logic to initialize and close the driver automatically.

Example:

.. code-block:: python

from toolium.test_cases import SeleniumTestCase
from web_nose2.pageobjects.login import LoginPageObject

class LoginTest(SeleniumTestCase):
def test_successful_login(self):
user = {'username': 'tomsmith', 'password': 'SuperSecretPassword!'}
secure_area = LoginPageObject().open().login(user)
self.assertIn('You logged into a secure area!', secure_area.message.get_message())

You can see a complete example of nose2 integration with Toolium in `toolium-examples repository <https://github.com/Telefonica/toolium-examples/tree/master/web_nose2>`_.

Pytest
~~~~~~

To run tests with pytest using Toolium, simply import Toolium's fixtures in your `conftest.py` file:

.. code-block:: python

from toolium.pytest_fixtures import *

This will automatically initialize the driver before each test, module, or session, and close it automatically after
the test execution, according to your configuration.

Example:

.. code-block:: python

from web_nose2.pageobjects.login import LoginPageObject

def test_successful_login():
user = {'username': 'tomsmith', 'password': 'SuperSecretPassword!'}
secure_area = LoginPageObject().open().login(user)
assert 'You logged into a secure area!' in secure_area.message.get_message()

You can see a complete example of pytest integration with Toolium in `toolium-examples repository <https://github.com/Telefonica/toolium-examples/tree/master/web_pytest>`_.

Pytest also allows to run tests that extend from a ``unittest.TestCase`` class. In this case, it is recommended to
extend directly from ``unittest.TestCase``, not from Toolium's test case classes. In this scenario, the driver will be
initialized using the Toolium fixtures (as shown above), not with setUp and tearDown methods. This ensures proper driver
management and compatibility with pytest's fixture system.

Example:

.. code-block:: python

import unittest
from web_nose2.pageobjects.login import LoginPageObject

class LoginTest(unittest.TestCase):
def test_successful_login(self):
user = {'username': 'tomsmith', 'password': 'SuperSecretPassword!'}
secure_area = LoginPageObject().open().login(user)
self.assertIn('You logged into a secure area!', secure_area.message.get_message())
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@ addopts = "-v --tb=short"
[tool.coverage.run]
source = ["toolium"]
omit = [
"*/test*",
"*/tests/*",
"*/venv/*",
"*/.venv/*",
"*/test/*"
]

[tool.coverage.report]
Expand Down
Loading