what is the error of cucumber.runtime.CucumberException: Arity mismatch: Step Definition in selenium with Java(cucumber.runtime.CucumberException 的错误是什么:Arity mismatch: Step Definition in selenium with Java)
问题描述
我写了一个特性文件来测试创建元素按钮.但它会生成
I have wrritten a feature file to test the create elements button. But it generates an error message of
cucumber.runtime.CucumberException: Arity mismatch: Step Definition.
我不知道为什么会这样,因为我是自动化测试的新手.
I dont know why its happening since I am new to automation testing.
以下是我自己写的代码
@When("^create elements$")
public void create_elements_for_attributes(WebElement elementToClick) throws Throwable {
driver.findElement(By.id("newElement")).click();
}
我收到的错误如下.
cucumber.runtime.CucumberException: Arity mismatch: Step Definition 'mCollector.features.StepDefinitions_mCollector.create_elements_for_attributes(WebElement) in file:/C:/Users/Admin/workspace/MStudio%20-%20eBilling/bin/' with pattern [^create elements$] is declared with 1 parameters. However, the gherkin step has 0 arguments [].
推荐答案
在您的 create_elements_for_attributes
方法中,您需要一个 WebElement
类型的参数,但您的正则表达式没有捕获任何论据.它应该看起来像这样:
In your create_elements_for_attributes
method you are expecting one argument of type WebElement
but your regex does not capture any arguments. It should look something like that instead:
@When("^create elements "([^"]*)"$")
然后在你的功能文件中:
And then in your feature file:
When create elements "element"
但这也行不通,因为您无法从 Cucumber 功能文件中传递 WebeElement
对象.您应该只使用原始值和数据表进行操作.其他类型(如 WebeElement)
应在胶水代码本身内部创建.
But that won't work either because you can't pass a WebeElement
object from your Cucumber feature file. You should only operate with primitive values and DataTables. Other types (like WebeElement)
should be created internally in the glue code itself.
这篇关于cucumber.runtime.CucumberException 的错误是什么:Arity mismatch: Step Definition in selenium with Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:cucumber.runtime.CucumberException 的错误是什么:Arity mismatch: Step Definition in selenium with Java
基础教程推荐
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01