【发布时间】:2015-12-07 14:08:42
【问题描述】:
我有一个描述登录帐户的方案文件;
Scenario: Failed login with blank login details
Given I go to "BBC Login Page"
When I fill in the username textfield with ""
And I fill in the password textfield with ""
And I press "Log in"
Then I should see "In order to login, you must enter a valid user name."
在我的步骤定义中(Python 使用 Lettuce),除非我在我的场景中传入 URL,否则会失败(坏 BDD);
@step('I go to "(.*?)"$')
def go_to(step, url):
with AssertContextManager(step):
world.browser.get(url)
相反,我想构建一些逻辑,将路径替换为真实的 URL;
msr_login_page = "https://www.bbc.co.uk/login"
@step('I go to "(.*?)"$')
def go_to(step, url):
if url == "BBC Login page":
urladjusted = msr_login_page
with AssertContextManager(step):
world.browser.get(urladjusted)
这会因错误而失败,而且无论我如何尝试设置它,我似乎都无法设置 URL 变量。
提前感谢您的帮助
【问题讨论】:
-
“失败并出现错误” - 什么错误?
-
pycharm中的错误是Message: f.QueryInterface is not a function
-
步骤定义中的缩进是否只是在将其复制到 Stack Overflow 时出现的拼写错误? if 语句应该缩进。