Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cucumber/Webrat:通过CSS类跟踪链接?_Css_Ruby_Css Selectors_Cucumber_Webrat - Fatal编程技术网

Cucumber/Webrat:通过CSS类跟踪链接?

Cucumber/Webrat:通过CSS类跟踪链接?,css,ruby,css-selectors,cucumber,webrat,Css,Ruby,Css Selectors,Cucumber,Webrat,是否可以按链接的类名而不是id、文本或标题跟随链接?既然我有哈哈,他呢?以下html代码: <div id="some_information_container"> <a href="edit" class="edit_button">Translation here</a> </div> 我不想通过文本匹配,因为我必须关心测试中的翻译值 我想让我的按钮看起来都一样,所以我将使用CSS类。 我不想为每个链接分配一个id,因为其中一些链接是通

是否可以按链接的类名而不是id、文本或标题跟随链接?既然我有哈哈,他呢?以下html代码:

<div id="some_information_container">
  <a href="edit" class="edit_button">Translation here</a>
</div>
我不想通过文本匹配,因为我必须关心测试中的翻译值 我想让我的按钮看起来都一样,所以我将使用CSS类。 我不想为每个链接分配一个id,因为其中一些链接是通过容器和link类完全识别的 Cucumber/Webrat中有什么我遗漏的吗?或者你有什么建议可以更好地解决这个问题

谢谢你的帮助和问候


编辑:我发现一个关于这个话题的有趣的讨论正在进行——现在似乎仍然是一个悬而未决的问题。您还有其他解决方案吗?

我对WebRat API不是很熟悉,但是使用DOM查找来获取您要查找的类的引用ID,然后将其传递给click\u link函数怎么样

下面是一些javascript的链接,用于按类检索项。

现在我想了想,使用Javascript简单地将其更改为某个随机ID,然后单击该ID,怎么样


不管是哪种方式,这都应该一直有效,直到关于包含getbyclass函数的名称的简单争论得到解决。

标记是否适合您


请标记“a.edit”按钮

以下是我如何使用cucumber的,希望能有所帮助。步骤定义中的帮助CSS理解发生了什么

这只适用于ID而不是类名

步骤定义

特征


下面是如何在类名为edit_botton的元素中断言文本

Then I should see "Translation here" within "[@class='edit_button']"

查找“a.some-class”怎么样?单击?

我添加了ruby标记,Brian。
Scenario Outline: Create Project
  When I fill in name with <title>
      And I select <data_type> from data_type
      And I press "Create"
  Then I should see <title> within a div with id "specifications"

Scenarios: Search Terms and Results
   | data_type  | title        |
   | Books      | A Book Title |
Then I should see "Translation here" within "[@class='edit_button']"