标签: cucumber

如何使用capybara + cucumber在ruby中断言html表行的数量

我正在尝试使用黄瓜+水豚来处理Ruby中的BDD Web开发,我仍然坚持应该是一个简单的任务 - 只是为了检查表中的行数.我想要实现的目的是:

page.should have_xpath("//table[@id='myTable']")
find("//table[@id='myTable']/tr").length.should == 3
Run Code Online (Sandbox Code Playgroud)

但这不起作用(缺少方法长度),我找不到一种方法来断言表长度.

任何想法任何人(请对我很轻松'我是一个红宝石nooby)

提前致谢

尼尔

ruby cucumber capybara

38
推荐指数
4
解决办法
2万
查看次数

是否有任何非开发人员工具来编辑小黄瓜文件?

Gherkin语法文件只是纯文本,因此可以使用任何编辑器,如记事本.但是,我们使用它的一个更重要的事情是提供样本数据表.没有良好的格式化选项,文件变得难以阅读.

对于visual studio,如specflow.org或https://github.com/henritersteeg/cuke4vs,有一些很好的工具(请参阅:如何在Visual Studio中为.feature文件突出显示Gherkin语法?).使用eclipse的开发人员的另一个选项在Cucumber IDE中讨论了使用自动完成功能编写功能吗?但是,我不想要求我们的业务分析师安装它.

这是一个语法高亮显示文件(http://productive.me/develop/cucumbergherkin-syntax-highlighting-for-notepad/),可以导入到notepad ++中,但它对表格格式没有任何作用.

我是否还有其他选择可以让非开发人员有效地编辑.feature小黄瓜文件?

bdd cucumber specflow gherkin

36
推荐指数
3
解决办法
2万
查看次数

你如何POST到Capybara的URL?

刚刚从Cucumber + Webrat切换到Cucumber + Capybara,我想知道如何将内容发布到Capybara的URL.

在Cucumber + Webrat中我能够迈出一步:

When /^I send "([^\"]*)" to "([^\"]*)"$/ do |file, project|
  proj = Project.find(:first, :conditions => "name='#{project}'")
  f = File.new(File.join(::Rails.root.to_s, file))
  visit "project/" + proj.id.to_s + "/upload",
        :post, {:upload_path => File.join(::Rails.root.to_s, file)}
end
Run Code Online (Sandbox Code Playgroud)

但是,Capybara文档提到:

visit方法只接受一个参数,请求方法总是GET.always GET.

如何修改我的步骤以便Cucumber + Capybara对URL进行POST?

ruby-on-rails webrat cucumber capybara

34
推荐指数
5
解决办法
3万
查看次数

我一直在使用Cucumber的IntelliJ中获得错误"未实现的子步骤定义"?

我已经:

  • 下载了Cucumber Java,Gherkin plugin
  • 我已经拥有the stepsfeatures目录:

我的目录结构如下所示:

- test
    - java
        - features
            - featureSet1
                - oneFeature.feature
                - anotherFeature.feature
            - featuresSet2
                - twoFeature.feature
            - CucumberTests.java
        - steps
                - step1.java
                - step2.java
Run Code Online (Sandbox Code Playgroud)

在features文件夹下,我有一个名为的文件CucumberTests.java.我能够通过测试来运行,mvn test但是红色错误标记真的让我烦恼.

我有这些标签CucumberTest.java,应该运行测试:

@RunWith(Cucumber.class)
@CucumberOptions(plugin = { "pretty", "html:target/surefire-
    reports/cucumber", "json:target/surefire-
    reports/cucumberOriginal.json"},
             features = {"src/test/java/features/featuresSet1",
                         "src/test/java/features/featuresSet2",
                         },
             tags = {"~@ignore"},
             glue = {"steps"})
Run Code Online (Sandbox Code Playgroud)

cucumber intellij-idea-2016

33
推荐指数
1
解决办法
1万
查看次数

Cucumber Capybara滚动到页面底部

我想使用我的Cucumber/Capybara设置通过驱动浏览器并滚动到页面底部来测试无限滚动,以确保加载新内容.有没有办法做到这一点?

cucumber capybara

32
推荐指数
2
解决办法
2万
查看次数

如何使用水豚来验证记录数量

我在Rails 2.3.9项目中使用水豚和黄瓜.

我有用户索引页面,我有两个记录.使用capybara如何断言页面中只有两条记录.

HTML结构是这样的

<div class='records'>
  <li>record 1<li>
  <li>record 2 </li>
</div>
Run Code Online (Sandbox Code Playgroud)

html ruby cucumber capybara

31
推荐指数
1
解决办法
1万
查看次数

我可以在specflow(或小黄瓜)中逃脱管道

我有一个specflow步骤表,我希望将|(管道)字符作为内容的一部分.

例:

Then the data should be
    | Field     | Value  |
    | SomeField | a|b|c  |
Run Code Online (Sandbox Code Playgroud)

但这不起作用.我怎样才能逃脱管道角色?

cucumber specflow gherkin

31
推荐指数
1
解决办法
9810
查看次数

无法使字段 private Final java.util.Comparator java.util.TreeMap.comparator 可访问:java.base 不会向未命名模块“打开 java.util”

我创建了一个 Cucumber 功能文件和步骤文件,然后单击功能文件的“运行配置”,我在控制台中看到以下内容。我怎么解决这个问题?

\n
*Feature: Login into account\n  Existing user should be able to login to account using correct credentials\n  \nScenario: Login into account with correct credentials     # C:/Users/MI/Desktop/CucumberFramework/CucumberFramework/src/test/java/CucumberFramework/featureFiles/Login.feature:4\n    \nGiven User navigates to stackoverflow website           # LoginSteps.user_navigates_to_stackoverflow_website()\n      java.lang.ExceptionInInitializerError\n        at cucumber.deps.com.thoughtworks.xstream.XStream.setupConverters(XStream.java:820)\n        at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:574)\n        at cucumber.deps.com.thoughtworks.xstream.XStream.<init>(XStream.java:530)\n        at cucumber.runtime.xstream.LocalizedXStreams$LocalizedXStream.<init>(LocalizedXStreams.java:50)\n        at cucumber.runtime.xstream.LocalizedXStreams.newXStream(LocalizedXStreams.java:37)\n        at cucumber.runtime.xstream.LocalizedXStreams.get(LocalizedXStreams.java:29)\n        at cucumber.runtime.StepDefinitionMatch.runStep(StepDefinitionMatch.java:37)\n        at cucumber.runtime.Runtime.runStep(Runtime.java:300)\n        at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)\n        at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)\n        at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)\n        at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)\n        at cucumber.runtime.Runtime.run(Runtime.java:122)\n        at cucumber.api.cli.Main.run(Main.java:36)\n        at cucumber.api.cli.Main.main(Main.java:18)\n        at \xe2\x9c\xbd.Given User navigates to stackoverflow website(C:/Users/MI/Desktop/CucumberFramework/CucumberFramework/src/test/java/CucumberFramework/featureFiles/Login.feature:5)\n     \n Caused by: java.lang.reflect.InaccessibleObjectException: Unable …
Run Code Online (Sandbox Code Playgroud)

java bdd cucumber selenium-webdriver

30
推荐指数
3
解决办法
8万
查看次数

运行osascript -e'告诉应用程序"TextMate"重新加载捆绑包时出错

我正在尝试为TextMate2安装Cucumber包.我按照官方网页https://github.com/cucumber/cucumber-tmbundle的以下说明进行操作:

mkdir -p ~/Library/Application\ Support/TextMate/Bundles/
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/cucumber/cucumber-tmbundle.git Cucumber.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'
Run Code Online (Sandbox Code Playgroud)

运行第4行:osascript -e'告诉应用程序"TextMate"重新加载包'后,我收到以下错误:

23:37: syntax error: A identifier can’t go after this identifier. (-2740)
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

bash textmate cucumber textmatebundles textmate2

29
推荐指数
1
解决办法
9380
查看次数

Selenium-chromedriver:无法从不可输入的键构造 KeyEvent

我昨天将 Chrome 和 Chromedriver 更新到了最新版本,从那时起,我在运行 Cucumber 功能时收到以下错误消息:

....
unknown error: Cannot construct KeyEvent from non-typeable key
        (Session info: chrome=98.0.4758.80) (Selenium::WebDriver::Error::UnknownError)
      #0 0x55e9ce6a4093 <unknown>
      #1 0x55e9ce16a648 <unknown>
      #2 0x55e9ce1a9866 <unknown>
      #3 0x55e9ce1cbd29 <unknown>
      .....
Run Code Online (Sandbox Code Playgroud)

我尝试用水豚的fill_in方法填充文本字段。在调试时,我注意到 Capybara 有问题,尤其是符号@\。其他所有字符都可以毫无问题地写入文本字段。

触发错误的代码如下所示

def sign_in(user)
  visit new_sign_in_path
  fill_in 'Email', with: user.email
  fill_in 'Password', with: user.password
  click_button 'Sign in'
end
Run Code Online (Sandbox Code Playgroud)

user.email包含一个类似 的字符串"example1@mail.com"

我使用 Rails 6.1.3.1、Cucumber 5.3.0、Chromedriver 98.0.4758.48、capybara 3.35.3

该错误仅发生在标记为@javascript

您有什么想法导致此错误或如何修复它吗?

ruby-on-rails cucumber capybara selenium-chromedriver

29
推荐指数
1
解决办法
7935
查看次数