如何搜索字段并确认它是空的?

时间:2014-06-20 07:50:49

标签: ruby cucumber

我是Ruby的新手,我已经被深深地用在黄瓜中使用它来编写测试套件而没有时间学习它。

我尝试编写一行代码来检查网页上是否存在某个字段,并且该字段为空白。

到目前为止,我已经:

Then /^I can verify that the fleet field is blank$/ do
  find_by_id('fleet', :text == nil)
end

我写的两个功能是:

Scenario: US1020-1  Confirm that the Date of Liability field is blank on screen
    When I navigate to the fleet vehicle search screen
    Then I can search for a valid record using Fleet number: "123456"
    And Registration number: "N253CSL"
    Then I can verify that the fleet field is blank


Scenario: US1020-2  Confirm that the Date of Liability field is blank on screen
    When I navigate to the fleet vehicle search screen
    And Registration number: "N253CSL"
    Then I can verify that the fleet field is blank

情景US1020 - 1应该会失败,因为我已经填充了与123456一起使用的机队,但它已经通过了。

N.B。测试的其他元素的ruby代码,连接到网页,填写字段已经写好了。

任何对菜鸟的帮助都会很棒。

由于

1 个答案:

答案 0 :(得分:0)

尝试:

Then /^I can verify that the fleet field is blank$/ do
  expect(find_by_id('fleet').value).to be_blank
end