Pytest-bdd integration with selenium base #1200
-
Hello Team, Background: Scenario: Speed Test Step Defs is scenarios('../features/speedtest.feature') class SpeedTest(BaseCase): @when('User clicks on check speed button') @then('Speed details are saved') When I run pytest it opens the browser but does nothing . If I run the code without pytest-bdd using following it works |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hi @taruntechno, when using https://github.com/pytest-dev/pytest-bdd with SeleniumBase, you may need to use the SeleniumBase Here's what the # "sb" pytest fixture test in a method with no class
def test_sb_fixture_with_no_class(sb):
sb.open("https://google.com/ncr")
sb.type('input[title="Search"]', "SeleniumBase GitHub\n")
sb.click('a[href*="github.com/seleniumbase/SeleniumBase"]')
sb.click('a[title="seleniumbase"]')
# "sb" pytest fixture test in a method inside a class
class Test_SB_Fixture:
def test_sb_fixture_inside_class(self, sb):
sb.open("https://google.com/ncr")
sb.type('input[title="Search"]', "SeleniumBase GitHub\n")
sb.click('a[href*="github.com/seleniumbase/SeleniumBase"]')
sb.click('a[title="examples"]') |
Beta Was this translation helpful? Give feedback.
-
@mdmintz it seems to be running two tests and i dont think its respecting bdd collected 2 items tests/step_defs/test_speed.py::test_bell_internet PASSED [ 50%] |
Beta Was this translation helpful? Give feedback.
Hi @taruntechno, when using https://github.com/pytest-dev/pytest-bdd with SeleniumBase, you may need to use the SeleniumBase
sb
fixture format for compatibility. (Numbers 3 and 4 of syntax_formats)Here's what the
sb
fixture format looks like, shown below: (pytest-bdd can be added onto that separately)