【发布时间】:2014-12-11 00:17:34
【问题描述】:
我正在使用 Cucumber 和 SitePrism 编写自动化测试。一项测试将用户角色添加到列表中,但我无法在最后步骤中验证角色是否存在(以验证它是否已成功分配)。
小黄瓜是……
Scenario: Assigning roles to a user
Given I have reached the user edit view in the admin
When I click the Assign Roles tab
And select the first value in the Add Role dropdown
And click Add role
Then I should receive the message of save successful
And the role should be present in the current role list
...And the role should be present in the current role list 是我遇到问题的步骤。 And click Add role 步骤执行后,列表的 HTML 将显示为这样...
<dd>
<select id="current-role-a02322d1-8add-4234-aeca-02d3fca2a239" class="current-role" name="role_id" multiple="multiple">
<option title="System Administrator Role" value="1">Administrator</option>
</select>
</dd>
这个我卡住了。我在页面模型上将元素设置为什么,我在步骤定义中写什么来验证<option title="System Administrator Role" value="1">Administrator</option> 的存在,如果它不存在则使步骤失败?我更愿意检查 value="1" 而不是 title 或文本。
提前感谢您的帮助!
【问题讨论】:
-
当你的问题中有黄瓜的代码时,你为什么要标记
Capybara? -
标签应该与问题中直接涉及的内容相关。人们关心,因为适当地策划问题是 StackOverflow 的全部意义所在。
-
我认为这个问题与 Cucumber 无关。您可以在步骤定义中使用您选择的任何库,问题似乎是关于编写与网页交互的步骤定义。
标签: ruby automation cucumber qa