Recipes¶
This plugin is an adapter for the microphone of ScreenPy’s Narrator which sends logs to Allure.
This example makes use of this plugin.
Plugging In the Adapter¶
Plugging the AllureAdapter
into the Narrator’s microphone
must be done during test setup.
This will be in your conftest.py
file for pytest,
or during suite configuration for unittest.
Either way, the steps are the same, wherever you need to do them:
from screenpy.pacing import the_narrator
from screenpy_adapter_allure import AllureAdapter
the_narrator.attach_adapter(AllureAdapter())
After that the steps are attached to the allure report
Attach Screenshot from Selenium¶
If you are using allure in a Selenium project using ScreenPy Selenium,
you can attach a new screenshot to the report
using SaveScreenshot
.
For example, you can attach a screenshot as a PNG:
from screenpy import Actor, Visit
from allure_commons.types import AttachmentType
filepath = 'screenshot.png'
the_actor = Actor.named("Perry").who_can(BrowseTheWeb.using_firefox())
docs_url = (
"https://screenpy-adapter-allure-docs.readthedocs.io/en/latest/cookbook.html"
)
the_actor.attempts_to(
Visit(docs_url),
SaveScreenshot.as_(filepath).and_attach_it_with(
attachment_type=AttachmentTypes.PNG,
),
)
Here is a screenshot of the report from
the github example.
In that example,
we go to GitHub’s search page
and find the screenpy_examples
repository.