Closed gilmrjc closed 5 days ago
You should either use splinter as it is suggested in documentation or... make a fixture out of your browser and yield it like in this post: https://automationpanda.com/2018/10/22/python-testing-101-pytest-bdd/
@pytest.fixture
def browser():
b = webdriver.Firefox()
b.implicitly_wait(10)
yield b
b.quit()
Also, I hope you use BDD as it is prescribed. If you setup webdriver in the background it does not seem right. The same with Selenium use Page Object Model.
As we are aiming for 100% Gherkin/Cucumber compatibility, this is not something that is currently accepted as a feature request for the Gherkin syntax. See https://github.com/cucumber/gherkin/issues/94
As mentioned in the last reply, however, fixtures that yield can be used for setups/teardowns for tests and are probably the right way to go.
pytest-BDD have the option to use background steps to SetUp the scenario before testing, but in my use case I use Selenium to do Aceptance Testing and there is no obvious place to put my webdriver.quit(). Is It posible to add another step like background to TearDown the scenario?
What I do for now is add a final step like Then I close the browser. I think a Finally step would be cleaner and can be extended over multiple scenarios in a feature.