Cha*_*ani 8 java automated-tests cucumber selenium-webdriver
我已经编写了一个功能文件来测试创建元素按钮.但它会生成错误消息
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)
在您的create_elements_for_attributes方法中,您需要一个类型的参数,WebElement但您的正则表达式不捕获任何参数。它应该看起来像这样:
@When("^create elements \"([^\"]*)\"$")
Run Code Online (Sandbox Code Playgroud)
然后在您的功能文件中:
When create elements "element"
Run Code Online (Sandbox Code Playgroud)
但这也行不通,因为您无法WebeElement从 Cucumber 功能文件中传递对象。您应该只使用原始值和数据表进行操作。其他类型(比如WebeElement)应该在胶水代码本身内部创建。
| 归档时间: |
|
| 查看次数: |
14685 次 |
| 最近记录: |