黄瓜,示例:如何验证该值与相邻列中的值完全相同

时间:2018-06-19 12:48:12

标签: selenium cucumber

网站上有2列...

在我的Selenium测试用例中,示例中的值是:

Examples:
| userrol  | information 1 | information 2 |
| role 1   | test          | rest          | 
| role 2   | test2         | rest2         |

现在,我可以测试这些值是否显示在网站上。 但是如何验证rest2是test2的邻居?

并且在网站上不这样:

| USER     | information1  | information2  |
| role 1   | test          | rest2         | 
| role 2   | test2         | rest          |

(它不仅应该测试是否显示,还应该测试它旁边的列中的文本是否对应)

1 个答案:

答案 0 :(得分:0)

您必须在html中包含一个contains元素,以便可以测试test2旁边的test,例如与

div#row
  span#info1  test
  span#info2  rest

您可以像水豚一样写东西

expect(page).to have_css('#row info1', text: 'test')
expect(page).to have_css('#row info2', text: 'rest')

如果您在源代码中没有其他标识符,css类或html可以简单地做到这一点,则可以修改源代码,或使用更复杂的css / xpath查询(谷歌“ css兄弟姐妹”)