小编Cha*_*ani的帖子

cucumber.runtime.CucumberException的错误是什么:Arity不匹配:使用Java在selenium中的步骤定义

我已经编写了一个功能文件来测试创建元素按钮.但它会生成错误消息

cucumber.runtime.CucumberException: Arity mismatch: Step Definition. 
Run Code Online (Sandbox Code Playgroud)

我不知道为什么它会发生,因为我是自动化测试的新手.

以下是我编写的代码.

@When("^create elements$")
public void create_elements_for_attributes(WebElement elementToClick) throws Throwable {
driver.findElement(By.id("newElement")).click();
}
Run Code Online (Sandbox Code Playgroud)

我收到的错误如下.

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 [].
Run Code Online (Sandbox Code Playgroud)

java automated-tests cucumber selenium-webdriver

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