这就是我编写 SeleniumBase/pytest-bdd 测试的方式:
ddg.feature:
Feature: Browse DuckDuckGo
Going to DuckDuckGo webpage.
Scenario: I can see the title
When I go to DuckDuckGo webpage
Then Duck is present in the title
test_ddg.py:
from seleniumbase import BaseCase
from pytest_bdd import scenarios, when, then
scenarios("./ddg.feature")
class MyTestClass(BaseCase):
@when("I go to DuckDuckGo webpage")
def go_to_ddg(self):
self.open('https://duckduckgo.com/')
@then("Duck is present in the title")
def is_title_present(self):
assert 'Duck' in self.get_title()
但是,这是行不通的。场景()函数看不到when和then描述符。
如果可能的话,知道如何进行这项工作吗?