Closed spyoungtech closed 5 years ago
@urosn74 -- feel free to checkout this branch and see if this meets your expectations. So far, I've only tested the environment variable transformer, but I believe this has the components you're looking for.
I've presented the feature as a fixture. So, to use it across all step definitions in the library, you can do the following
from behave.fixtures import use_fixture
from behave_webdriver.transformers import EnvironmentFormatTransformer
def before_all(context):
use_fixture(EnvironmentFormatTransformer, context)
You can also use this on a per-scenario or per-feature basis using tags like so
Feature: Using a transformation fixture from feature file
@fixture.transformer.EnvironmentFormatTransformer
Scenario: transform step from environment variable
Given the base url is "{ENV_BASE_URL}"
When I open the site "/page.html"
Then I expect that the url is "http://127.0.0.1:8000/page.html"
Then in your environment file
from behave_webdriver import use_fixture_tag
def before_tag(context, tag):
use_fixture_tag(context, tag)
Then it will automagically find the transformer class and apply it when the tag is used.
So, if you set an environment variable ENV_BASE_URL
and then run the feature file test
behave tests/features/transformation_fixture.feature
You should get an output something like
Feature: Using a transformation fixture from feature file # tests/features/transformation_fixture.feature:1
@fixture.transformer.EnvironmentFormatTransformer
Scenario: transform step from environment variable # tests/features/transformation_fixture.feature:4
Given the base url is "{ENV_BASE_URL}" # behave_webdriver/steps/actions.py:164
When I open the site "/page.html" # behave_webdriver/steps/actions.py:157
Then I expect that the url is "http://127.0.0.1:8000/page.html" # behave_webdriver/steps/expectations.py:149
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m2.556s
Hi @spyoungtech. That was superfast :-)
I am a bit tight with my time, but will try to test this this evening.
Addresses #61
Also adds some other really exciting things and capabilities I wasn't sure would be possible.
Still need to write some more tests, work on Py2 compatibility (or maybe we'll drop support for Py2), but looks really promising so far.